Removing the message "userrights-logcomment", which was never used and is redundant...
[mediawiki.git] / maintenance / updateArticleCount.inc.php
blob20546a78c255a07fbca413a3ef3860138388714e
1 <?php
3 /**
4 * Support class for the updateArticleCount.php maintenance script
6 * @package MediaWiki
7 * @subpackage Maintenance
8 * @author Rob Church <robchur@gmail.com>
9 */
11 class ArticleCounter {
13 var $dbr;
14 var $namespaces;
16 function ArticleCounter() {
17 global $wgContentNamespaces;
18 $this->namespaces = $wgContentNamespaces;
19 $this->dbr =& wfGetDB( DB_SLAVE );
22 /**
23 * Produce a comma-delimited set of namespaces
24 * Includes paranoia
26 * @return string
28 function makeNsSet() {
29 foreach( $this->namespaces as $namespace )
30 $namespaces[] = intval( $namespace );
31 return implode( ', ', $namespaces );
34 /**
35 * Produce SQL for the query
37 * @return string
39 function makeSql() {
40 extract( $this->dbr->tableNames( 'page', 'pagelinks' ) );
41 $nsset = $this->makeNsSet();
42 return "SELECT COUNT(*) AS count FROM {$page}
43 LEFT JOIN {$pagelinks} ON pl_from = page_id
44 WHERE page_namespace IN ( $nsset )
45 AND page_is_redirect = 0
46 AND page_len > 0
47 AND pl_namespace IS NOT NULL";
50 /**
51 * Count the number of valid content pages in the wiki
53 * @return mixed Integer, or false if there's a problem
55 function count() {
56 $res = $this->dbr->query( $this->makeSql(), __METHOD__ );
57 if( $res ) {
58 $row = $this->dbr->fetchObject( $res );
59 $this->dbr->freeResult( $res );
60 return (int)$row->count;
61 } else {
62 return false; # Look out for this when handling the result