From: umherirrender Date: Thu, 13 Dec 2012 20:05:15 +0000 (+0100) Subject: (bug 42089) meta=siteinfo should output the default content model X-Git-Tag: 1.31.0-rc.0~21309^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=bf9bd497f04a961b4877aa83543b7f4bc92f5999;p=lhc%2Fweb%2Fwiklou.git (bug 42089) meta=siteinfo should output the default content model Adding MWNamespace::getNamespaceContentModel which returns the namespace content model from the global, if set Change-Id: Ie012fd0ff846d50cae8081fc32b76900dbcad209 --- diff --git a/includes/Namespace.php b/includes/Namespace.php index e8d5632d88..46af0029a2 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -419,4 +419,18 @@ class MWNamespace { return $wgNonincludableNamespaces && in_array( $index, $wgNonincludableNamespaces ); } + /** + * Get the default content model for a namespace + * This does not mean that all pages in that namespace have the model + * + * @since 1.21 + * @param $index int Index to check + * @return null|string default model name for the given namespace, if set + */ + public static function getNamespaceContentModel( $index ) { + global $wgNamespaceContentModels; + return isset( $wgNamespaceContentModels[$index] ) + ? $wgNamespaceContentModels[$index] + : null; + } } diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index ec503d64a5..bb22448873 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -227,6 +227,11 @@ class ApiQuerySiteinfo extends ApiQueryBase { if ( MWNamespace::isNonincludable( $ns ) ) { $data[$ns]['nonincludable'] = ''; } + + $contentmodel = MWNamespace::getNamespaceContentModel( $ns ); + if ( $contentmodel ) { + $data[$ns]['defaultcontentmodel'] = $contentmodel; + } } $this->getResult()->setIndexedTagName( $data, 'ns' ); diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index b61dc34e4b..9d8db93808 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -185,8 +185,6 @@ abstract class ContentHandler { * @return null|string default model name for the page given by $title */ public static function getDefaultModelFor( Title $title ) { - global $wgNamespaceContentModels; - // NOTE: this method must not rely on $title->getContentModel() directly or indirectly, // because it is used to initialize the mContentModel member. @@ -194,11 +192,7 @@ abstract class ContentHandler { $ext = false; $m = null; - $model = null; - - if ( !empty( $wgNamespaceContentModels[ $ns ] ) ) { - $model = $wgNamespaceContentModels[ $ns ]; - } + $model = MWNamespace::getNamespaceContentModel( $ns ); // Hook can determine default model if ( !wfRunHooks( 'ContentHandlerDefaultModelFor', array( $title, &$model ) ) ) {