* @return int
*/
public function articles() {
- $config = MediaWikiServices::getInstance()->getMainConfig();
+ $services = MediaWikiServices::getInstance();
$tables = [ 'page' ];
$conds = [
- 'page_namespace' => MWNamespace::getContentNamespaces(),
+ 'page_namespace' => $services->getNamespaceInfo()->getContentNamespaces(),
'page_is_redirect' => 0,
];
- if ( $config->get( 'ArticleCountMethod' ) == 'link' ) {
+ if ( $services->getMainConfig()->get( 'ArticleCountMethod' ) == 'link' ) {
$tables[] = 'pagelinks';
$conds[] = 'pl_from=page_id';
- } elseif ( $config->get( 'ArticleCountMethod' ) == 'comma' ) {
- // To make a correct check for this, we would need, for each page,
- // to load the text, maybe uncompress it, maybe decode it and then
- // check if there's one comma.
- // But one thing we are sure is that if the page is empty, it can't
- // contain a comma :)
- $conds[] = 'page_len > 0';
}
$this->articles = $this->dbr->selectField(
/**
* @param int $index
- * @param string[] $groups
+ * @param string[]|string $groups
* @return IDatabase
*/
private static function getDB( $index, $groups = [] ) {
- $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
-
- return $lb->getConnection( $index, $groups );
+ return MediaWikiServices::getInstance()
+ ->getDBLoadBalancer()
+ ->getConnectionRef( $index, $groups );
}
}