X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialRandompage.php;h=c4ea005a5525f65f3a60e5d655191d50402acd0a;hp=d7835d1045d0d56ec716b1f5a8761f19e523dee2;hb=a3cd158d8433e41cbeb299f0e268dfef363b2afd;hpb=fc1ca75323b5f424a9f8d28d42d85a311ed2f721 diff --git a/includes/specials/SpecialRandompage.php b/includes/specials/SpecialRandompage.php index d7835d1045..c4ea005a55 100644 --- a/includes/specials/SpecialRandompage.php +++ b/includes/specials/SpecialRandompage.php @@ -22,6 +22,8 @@ * @author Rob Church , Ilmari Karonen */ +use MediaWiki\MediaWikiServices; + /** * Special page to direct the user to a random page * @@ -33,7 +35,8 @@ class RandomPage extends SpecialPage { protected $extra = []; // Extra SQL statements public function __construct( $name = 'Randompage' ) { - $this->namespaces = MWNamespace::getContentNamespaces(); + $this->namespaces = MediaWikiServices::getInstance()->getNamespaceInfo()-> + getContentNamespaces(); parent::__construct( $name ); } @@ -54,12 +57,11 @@ class RandomPage extends SpecialPage { } public function execute( $par ) { - global $wgContLang; - if ( is_string( $par ) ) { // Testing for stringiness since we want to catch // the empty string to mean main namespace only. - $this->setNamespace( $wgContLang->getNsIndex( $par ) ); + $this->setNamespace( + MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( $par ) ); } $title = $this->getRandomTitle(); @@ -85,17 +87,17 @@ class RandomPage extends SpecialPage { * @return string */ private function getNsList() { - global $wgContLang; + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); $nsNames = []; foreach ( $this->namespaces as $n ) { if ( $n === NS_MAIN ) { $nsNames[] = $this->msg( 'blanknamespace' )->plain(); } else { - $nsNames[] = $wgContLang->getNsText( $n ); + $nsNames[] = $contLang->getNsText( $n ); } } - return $wgContLang->commaList( $nsNames ); + return $contLang->commaList( $nsNames ); } /** @@ -159,7 +161,7 @@ class RandomPage extends SpecialPage { } private function selectRandomPageFromDB( $randstr, $fname = __METHOD__ ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $query = $this->getQueryInfo( $randstr ); $res = $dbr->select(