installer: Add a defined check to overrideConfig method
[lhc/web/wiklou.git] / includes / installer / Installer.php
index 9053f8d..ffa01c7 100644 (file)
@@ -494,7 +494,7 @@ abstract class Installer {
 
                $good = true;
                // Must go here because an old version of PCRE can prevent other checks from completing
-               list( $pcreVersion ) = explode( ' ', PCRE_VERSION, 2 );
+               $pcreVersion = explode( ' ', PCRE_VERSION, 2 )[0];
                if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION, '<' ) ) {
                        $this->showError( 'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
                        $good = false;
@@ -696,6 +696,7 @@ abstract class Installer {
                                'enableSectionEditLinks' => false,
                                'unwrap' => true,
                        ] );
+                       $html = Parser::stripOuterParagraph( $html );
                } catch ( Wikimedia\Services\ServiceDisabledException $e ) {
                        $html = '<!--DB access attempted during parse-->  ' . htmlspecialchars( $text );
                }
@@ -1203,9 +1204,11 @@ abstract class Installer {
                                }
 
                                try {
-                                       $text = Http::get( $url . $file, [ 'timeout' => 3 ], __METHOD__ );
+                                       $text = MediaWikiServices::getInstance()->getHttpRequestFactory()->
+                                               get( $url . $file, [ 'timeout' => 3 ], __METHOD__ );
                                } catch ( Exception $e ) {
-                                       // Http::get throws with allow_url_fopen = false and no curl extension.
+                                       // HttpRequestFactory::get can throw with allow_url_fopen = false and no curl
+                                       // extension.
                                        $text = null;
                                }
                                unlink( $dir . $file );
@@ -1761,7 +1764,9 @@ abstract class Installer {
        public static function overrideConfig() {
                // Use PHP's built-in session handling, since MediaWiki's
                // SessionHandler can't work before we have an object cache set up.
-               define( 'MW_NO_SESSION_HANDLER', 1 );
+               if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
+                       define( 'MW_NO_SESSION_HANDLER', 1 );
+               }
 
                // Don't access the database
                $GLOBALS['wgUseDatabaseMessages'] = false;