Merge "HTML escape parameter 'text' of hook 'SkinEditSectionLinks'"
[lhc/web/wiklou.git] / includes / specials / SpecialRandompage.php
index d7835d1..c4ea005 100644 (file)
@@ -22,6 +22,8 @@
  * @author Rob Church <robchur@gmail.com>, 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(