From cd40d0040cb9f6aabac622102341fb924947b2fe Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 5 May 2012 10:22:28 +0200 Subject: [PATCH] Add MWNamespace::isNonincludableNamespace Method is a wrapper around $wgNonincludableNamespaces, replaced the one place in parser and add it as info to api's meta=siteinfo Change-Id: I501b811137c39f5c2d9ea35c78fef8ae22d21bfe --- includes/Namespace.php | 12 ++++++++++++ includes/api/ApiQuerySiteinfo.php | 4 ++++ includes/parser/Parser.php | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/includes/Namespace.php b/includes/Namespace.php index ac788aaaac..bdccca16eb 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -354,4 +354,16 @@ class MWNamespace { return $index == NS_USER || $index == NS_USER_TALK; } + /** + * It is not possible to use pages from this namespace as template? + * + * @since 1.20 + * @param $index int Index to check + * @return bool + */ + public static function isNonincludableNamespace( $index ) { + global $wgNonincludableNamespaces; + return $wgNonincludableNamespaces && in_array( $index, $wgNonincludableNamespaces ); + } + } diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index e11d110526..9c1bef70dd 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -206,6 +206,10 @@ class ApiQuerySiteinfo extends ApiQueryBase { if ( MWNamespace::isContent( $ns ) ) { $data[$ns]['content'] = ''; } + + if ( MWNamespace::isNonincludableNamespace( $ns ) ) { + $data[$ns]['nonincludable'] = ''; + } } $this->getResult()->setIndexedTagName( $data, 'ns' ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index d5868a71d0..39f95096d7 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3071,7 +3071,7 @@ class Parser { * @private */ function braceSubstitution( $piece, $frame ) { - global $wgNonincludableNamespaces, $wgContLang; + global $wgContLang; wfProfileIn( __METHOD__ ); wfProfileIn( __METHOD__.'-setup' ); @@ -3301,7 +3301,7 @@ class Parser { $isHTML = true; $this->disableCache(); } - } elseif ( $wgNonincludableNamespaces && in_array( $title->getNamespace(), $wgNonincludableNamespaces ) ) { + } elseif ( MWNamespace::isNonincludableNamespace( $title->getNamespace() ) ) { $found = false; # access denied wfDebug( __METHOD__.": template inclusion denied for " . $title->getPrefixedDBkey() ); } else { -- 2.20.1