Merge "Fix 'Tags' padding to keep it farther from the edge and document the source...
[lhc/web/wiklou.git] / includes / installer / Installer.php
index 284d5dd..0890bc4 100644 (file)
@@ -23,6 +23,8 @@
  * @file
  * @ingroup Deployment
  */
+
+use MediaWiki\Interwiki\NullInterwikiLookup;
 use MediaWiki\MediaWikiServices;
 use MediaWiki\Shell\Shell;
 
@@ -404,7 +406,7 @@ abstract class Installer {
                $installerConfig = self::getInstallerConfig( $defaultConfig );
 
                // Reset all services and inject config overrides
-               MediaWiki\MediaWikiServices::resetGlobalInstance( $installerConfig );
+               MediaWikiServices::resetGlobalInstance( $installerConfig );
 
                // Don't attempt to load user language options (T126177)
                // This will be overridden in the web installer with the user-specified language
@@ -415,13 +417,19 @@ abstract class Installer {
                Language::getLocalisationCache()->disableBackend();
 
                // Disable all global services, since we don't have any configuration yet!
-               MediaWiki\MediaWikiServices::disableStorageBackend();
+               MediaWikiServices::disableStorageBackend();
 
+               $mwServices = MediaWikiServices::getInstance();
                // Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
                // SqlBagOStuff will then throw since we just disabled wfGetDB)
-               $wgObjectCaches = MediaWikiServices::getInstance()->getMainConfig()->get( 'ObjectCaches' );
+               $wgObjectCaches = $mwServices->getMainConfig()->get( 'ObjectCaches' );
                $wgMemc = ObjectCache::getInstance( CACHE_NONE );
 
+               // Disable interwiki lookup, to avoid database access during parses
+               $mwServices->redefineService( 'InterwikiLookup', function () {
+                       return new NullInterwikiLookup();
+               } );
+
                // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
                $wgUser = User::newFromId( 0 );
                RequestContext::getMain()->setUser( $wgUser );
@@ -811,7 +819,7 @@ abstract class Installer {
                // with utf8 support, but not unicode property support.
                // check that \p{Zs} (space separators) matches
                // U+3000 (Ideographic space)
-               $regexprop = preg_replace( '/\p{Zs}/u', '', "-\xE3\x80\x80-" );
+               $regexprop = preg_replace( '/\p{Zs}/u', '', "-\u{3000}-" );
                Wikimedia\restoreWarnings();
                if ( $regexd != '--' || $regexprop != '--' ) {
                        $this->showError( 'config-pcre-no-utf8' );
@@ -1107,29 +1115,6 @@ abstract class Installer {
                return true;
        }
 
-       /**
-        * Convert a hex string representing a Unicode code point to that code point.
-        * @param string $c
-        * @return string|false
-        */
-       protected function unicodeChar( $c ) {
-               $c = hexdec( $c );
-               if ( $c <= 0x7F ) {
-                       return chr( $c );
-               } elseif ( $c <= 0x7FF ) {
-                       return chr( 0xC0 | $c >> 6 ) . chr( 0x80 | $c & 0x3F );
-               } elseif ( $c <= 0xFFFF ) {
-                       return chr( 0xE0 | $c >> 12 ) . chr( 0x80 | $c >> 6 & 0x3F ) .
-                               chr( 0x80 | $c & 0x3F );
-               } elseif ( $c <= 0x10FFFF ) {
-                       return chr( 0xF0 | $c >> 18 ) . chr( 0x80 | $c >> 12 & 0x3F ) .
-                               chr( 0x80 | $c >> 6 & 0x3F ) .
-                               chr( 0x80 | $c & 0x3F );
-               } else {
-                       return false;
-               }
-       }
-
        /**
         * Check the libicu version
         */
@@ -1141,8 +1126,8 @@ abstract class Installer {
                 * Note that we use the hex representation to create the code
                 * points in order to avoid any Unicode-destroying during transit.
                 */
-               $not_normal_c = $this->unicodeChar( "FA6C" );
-               $normal_c = $this->unicodeChar( "242EE" );
+               $not_normal_c = "\u{FA6C}";
+               $normal_c = "\u{242EE}";
 
                $useNormalizer = 'php';
                $needsUpdate = false;
@@ -1612,23 +1597,11 @@ abstract class Installer {
        protected function doGenerateKeys( $keys ) {
                $status = Status::newGood();
 
-               $strong = true;
                foreach ( $keys as $name => $length ) {
-                       $secretKey = MWCryptRand::generateHex( $length, true );
-                       if ( !MWCryptRand::wasStrong() ) {
-                               $strong = false;
-                       }
-
+                       $secretKey = MWCryptRand::generateHex( $length );
                        $this->setVar( $name, $secretKey );
                }
 
-               if ( !$strong ) {
-                       $names = array_keys( $keys );
-                       $names = preg_replace( '/^(.*)$/', '\$$1', $names );
-                       global $wgLang;
-                       $status->warning( 'config-insecure-keys', $wgLang->listToText( $names ), count( $names ) );
-               }
-
                return $status;
        }