From efb1e7df095a557d6ee09e58d778c786aeffcf04 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 12 Jun 2006 11:59:12 +0000 Subject: [PATCH] Introduce $wgContentNamespaces which allows for articles to exist in namespaces other than the main namespace, and still be counted as valid content in the site statistics. --- RELEASE-NOTES | 3 ++- includes/Article.php | 4 ++-- includes/DefaultSettings.php | 8 ++++++++ maintenance/initStats.php | 3 ++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 569a49941b..a18f40d3b4 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -476,7 +476,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN for new normalization code when tidy not in use * Replace "nogomatch" with "noexactmatch" and place the magic colon in the messages themselves. Some minor tweaks to the actual message content. - +* Introduce $wgContentNamespaces which allows for articles to exist in namespaces other + than the main namespace, and still be counted as valid content in the site statistics. == Compatibility == diff --git a/includes/Article.php b/includes/Article.php index ecd5410528..2b3149311a 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -538,11 +538,11 @@ class Article { * @return bool */ function isCountable( $text ) { - global $wgUseCommaCount; + global $wgUseCommaCount, $wgContentNamespaces; $token = $wgUseCommaCount ? ',' : '[['; return - $this->mTitle->getNamespace() == NS_MAIN + array_search( $this->mTitle->getNamespace(), $wgContentNamespaces ) !== false && ! $this->isRedirect( $text ) && in_string( $token, $text ); } diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 88725317ad..782af969f9 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2067,4 +2067,12 @@ $wgReservedUsernames = array( 'MediaWiki default', 'Conversion script' ); */ $wgAllowTitlesInSVG = false; +/** + * Array of namespaces which can be deemed to contain valid "content", as far + * as the site statistics are concerned. Useful if additional namespaces also + * contain "content" which should be considered when generating a count of the + * number of articles in the wiki. + */ +$wgContentNamespaces = array( NS_MAIN ); + ?> diff --git a/maintenance/initStats.php b/maintenance/initStats.php index 06bb767101..b622c3f025 100644 --- a/maintenance/initStats.php +++ b/maintenance/initStats.php @@ -25,7 +25,8 @@ echo( "Counting total edits..." ); $edits = $dbr->selectField( 'revision', 'COUNT(*)', '', $fname ); echo( "{$edits}\nCounting number of articles..." ); -$good = $dbr->selectField( 'page', 'COUNT(*)', array( 'page_namespace' => 0, 'page_is_redirect' => 0, 'page_len > 0' ), $fname ); +global $wgContentNamespaces; +$good = $dbr->selectField( 'page', 'COUNT(*)', array( 'page_namespace' => $wgContentNamespaces, 'page_is_redirect' => 0, 'page_len > 0' ), $fname ); echo( "{$good}\nCounting total pages..." ); $pages = $dbr->selectField( 'page', 'COUNT(*)', '', $fname ); -- 2.20.1