Merge "Add columns option to Special:PrefixIndex"
[lhc/web/wiklou.git] / includes / installer / Installer.php
index e6b0fd3..48f850f 100644 (file)
@@ -41,6 +41,14 @@ abstract class Installer {
        // This is the absolute minimum PHP version we can support
        const MINIMUM_PHP_VERSION = '5.3.2';
 
+       /**
+        * The oldest version of PCRE we can support.
+        *
+        * Defining this is necessary because PHP may be linked with a system version
+        * of PCRE, which may be older than that bundled with the minimum PHP version.
+        */
+       const MINIMUM_PCRE_VERSION = '7.2';
+
        /**
         * @var array
         */
@@ -94,6 +102,7 @@ abstract class Installer {
                'mysql',
                'postgres',
                'oracle',
+               'mssql',
                'sqlite',
        );
 
@@ -108,11 +117,9 @@ abstract class Installer {
                'envCheckDB',
                'envCheckRegisterGlobals',
                'envCheckBrokenXML',
-               'envCheckPHP531',
                'envCheckMagicQuotes',
                'envCheckMagicSybase',
                'envCheckMbstring',
-               'envCheckZE1',
                'envCheckSafeMode',
                'envCheckXML',
                'envCheckPCRE',
@@ -339,15 +346,14 @@ abstract class Installer {
         * Constructor, always call this from child classes.
         */
        public function __construct() {
-               global $wgExtensionMessagesFiles, $wgUser;
+               global $wgMessagesDirs, $wgUser;
 
                // Disable the i18n cache and LoadBalancer
                Language::getLocalisationCache()->disableBackend();
                LBFactory::disableBackend();
 
-               // Load the installer's i18n file.
-               $wgExtensionMessagesFiles['MediawikiInstaller'] =
-                       __DIR__ . '/Installer.i18n.php';
+               // Load the installer's i18n.
+               $wgMessagesDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
 
                // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
                $wgUser = User::newFromId( 0 );
@@ -416,6 +422,15 @@ abstract class Installer {
                        $good = false;
                }
 
+               // Must go here because an old version of PCRE can prevent other checks from completing
+               if ( $good ) {
+                       list( $pcreVersion ) = explode( ' ', PCRE_VERSION, 2 );
+                       if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION, '<' ) ) {
+                               $this->showError( 'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
+                               $good = false;
+                       }
+               }
+
                if ( $good ) {
                        foreach ( $this->envChecks as $check ) {
                                $status = $this->$check();
@@ -490,8 +505,7 @@ abstract class Installer {
        }
 
        /**
-        * Determine if LocalSettings.php exists. If it does, return its variables,
-        * merged with those from AdminSettings.php, as an array.
+        * Determine if LocalSettings.php exists. If it does, return its variables.
         *
         * @return Array
         */
@@ -509,9 +523,6 @@ abstract class Installer {
 
                require "$IP/includes/DefaultSettings.php";
                require "$IP/LocalSettings.php";
-               if ( file_exists( "$IP/AdminSettings.php" ) ) {
-                       require "$IP/AdminSettings.php";
-               }
 
                return get_defined_vars();
        }
@@ -630,15 +641,19 @@ abstract class Installer {
                if ( !$status->isOK() ) {
                        return $status;
                }
-               $status->value->insert( 'site_stats', array(
-                       'ss_row_id' => 1,
-                       'ss_total_views' => 0,
-                       'ss_total_edits' => 0,
-                       'ss_good_articles' => 0,
-                       'ss_total_pages' => 0,
-                       'ss_users' => 0,
-                       'ss_images' => 0 ),
-                       __METHOD__, 'IGNORE' );
+               $status->value->insert(
+                       'site_stats',
+                       array(
+                               'ss_row_id' => 1,
+                               'ss_total_views' => 0,
+                               'ss_total_edits' => 0,
+                               'ss_good_articles' => 0,
+                               'ss_total_pages' => 0,
+                               'ss_users' => 0,
+                               'ss_images' => 0
+                       ),
+                       __METHOD__, 'IGNORE'
+               );
 
                return Status::newGood();
        }
@@ -717,23 +732,6 @@ abstract class Installer {
                return true;
        }
 
-       /**
-        * Test PHP (probably 5.3.1, but it could regress again) to make sure that
-        * reference parameters to __call() are not converted to null
-        * @return bool
-        */
-       protected function envCheckPHP531() {
-               $test = new PhpRefCallBugTester;
-               $test->execute();
-               if ( !$test->ok ) {
-                       $this->showError( 'config-using531', phpversion() );
-
-                       return false;
-               }
-
-               return true;
-       }
-
        /**
         * Environment check for magic_quotes_runtime.
         * @return bool
@@ -776,20 +774,6 @@ abstract class Installer {
                return true;
        }
 
-       /**
-        * Environment check for zend.ze1_compatibility_mode.
-        * @return bool
-        */
-       protected function envCheckZE1() {
-               if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
-                       $this->showError( 'config-ze1' );
-
-                       return false;
-               }
-
-               return true;
-       }
-
        /**
         * Environment check for safe_mode.
         * @return bool
@@ -826,11 +810,6 @@ abstract class Installer {
         * @return bool
         */
        protected function envCheckPCRE() {
-               if ( !function_exists( 'preg_match' ) ) {
-                       $this->showError( 'config-pcre' );
-
-                       return false;
-               }
                wfSuppressWarnings();
                $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
                // Need to check for \p support too, as PCRE can be compiled
@@ -1152,11 +1131,11 @@ abstract class Installer {
                        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 );
+                       . 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 );
+                       . chr( 0x80 | $c >> 6 & 0x3F )
+                       . chr( 0x80 | $c & 0x3F );
                } else {
                        return false;
                }
@@ -1744,7 +1723,7 @@ abstract class Installer {
                $GLOBALS['wgMaxShellMemory'] = 0;
 
                // Don't bother embedding images into generated CSS, which is not cached
-               $GLOBALS['wgResourceLoaderLESSFunctions']['embeddable'] = function( $frame, $less ) {
+               $GLOBALS['wgResourceLoaderLESSFunctions']['embeddable'] = function ( $frame, $less ) {
                        return $less->toBool( false );
                };
        }