Merge "Do not support new installations via .php5 entrypoint any longer"
[lhc/web/wiklou.git] / includes / installer / Installer.php
index c29b462..a10fb48 100644 (file)
@@ -146,7 +146,6 @@ abstract class Installer {
         * @var array
         */
        protected $envPreps = array(
-               'envPrepExtension',
                'envPrepServer',
                'envPrepPath',
        );
@@ -177,7 +176,6 @@ abstract class Installer {
                'wgGitBin',
                'IP',
                'wgScriptPath',
-               'wgScriptExtension',
                'wgMetaNamespace',
                'wgDeletedDirectory',
                'wgEnableUploads',
@@ -224,7 +222,7 @@ abstract class Installer {
 
                // $wgLogo is probably wrong (bug 48084); set something that will work.
                // Single quotes work fine here, as LocalSettingsGenerator outputs this unescaped.
-               'wgLogo' => '$wgScriptPath/resources/assets/wiki.png',
+               'wgLogo' => '$wgResourceBasePath/resources/assets/wiki.png',
        );
 
        /**
@@ -285,27 +283,27 @@ abstract class Installer {
        public $licenses = array(
                'cc-by' => array(
                        'url' => 'https://creativecommons.org/licenses/by/3.0/',
-                       'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-by.png',
+                       'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by.png',
                ),
                'cc-by-sa' => array(
                        'url' => 'https://creativecommons.org/licenses/by-sa/3.0/',
-                       'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-by-sa.png',
+                       'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-sa.png',
                ),
                'cc-by-nc-sa' => array(
                        'url' => 'https://creativecommons.org/licenses/by-nc-sa/3.0/',
-                       'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-by-nc-sa.png',
+                       'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-nc-sa.png',
                ),
                'cc-0' => array(
                        'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
-                       'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-0.png',
+                       'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-0.png',
                ),
                'pd' => array(
                        'url' => '',
-                       'icon' => '{$wgResourceBasePath}/resources/assets/licenses/public-domain.png',
+                       'icon' => '$wgResourceBasePath/resources/assets/licenses/public-domain.png',
                ),
                'gfdl' => array(
                        'url' => 'https://www.gnu.org/copyleft/fdl.html',
-                       'icon' => '{$wgResourceBasePath}/resources/assets/licenses/gnu-fdl.png',
+                       'icon' => '$wgResourceBasePath/resources/assets/licenses/gnu-fdl.png',
                ),
                'none' => array(
                        'url' => '',
@@ -540,9 +538,9 @@ abstract class Installer {
                global $wgAutoloadClasses;
                $wgAutoloadClasses = array();
 
-               wfSuppressWarnings();
+               MediaWiki\suppressWarnings();
                $_lsExists = file_exists( "$IP/LocalSettings.php" );
-               wfRestoreWarnings();
+               MediaWiki\restoreWarnings();
 
                if ( !$_lsExists ) {
                        return false;
@@ -830,14 +828,14 @@ abstract class Installer {
         * @return bool
         */
        protected function envCheckPCRE() {
-               wfSuppressWarnings();
+               MediaWiki\suppressWarnings();
                $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
                // Need to check for \p support too, as PCRE can be compiled
                // 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-" );
-               wfRestoreWarnings();
+               MediaWiki\restoreWarnings();
                if ( $regexd != '--' || $regexprop != '--' ) {
                        $this->showError( 'config-pcre-no-utf8' );
 
@@ -1140,9 +1138,6 @@ abstract class Installer {
         * Check the libicu version
         */
        protected function envCheckLibicu() {
-               $utf8 = function_exists( 'utf8_normalize' );
-               $intl = function_exists( 'normalizer_normalize' );
-
                /**
                 * This needs to be updated something that the latest libicu
                 * will properly normalize.  This normalization was found at
@@ -1156,18 +1151,7 @@ abstract class Installer {
                $useNormalizer = 'php';
                $needsUpdate = false;
 
-               /**
-                * We're going to prefer the pecl extension here unless
-                * utf8_normalize is more up to date.
-                */
-               if ( $utf8 ) {
-                       $useNormalizer = 'utf8';
-                       $utf8 = utf8_normalize( $not_normal_c, UtfNormal::UNORM_NFC );
-                       if ( $utf8 !== $normal_c ) {
-                               $needsUpdate = true;
-                       }
-               }
-               if ( $intl ) {
+               if ( function_exists( 'normalizer_normalize' ) ) {
                        $useNormalizer = 'intl';
                        $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
                        if ( $intl !== $normal_c ) {
@@ -1175,8 +1159,7 @@ abstract class Installer {
                        }
                }
 
-               // Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8',
-               // 'config-unicode-using-intl'
+               // Uses messages 'config-unicode-using-php' and 'config-unicode-using-intl'
                if ( $useNormalizer === 'php' ) {
                        $this->showMessage( 'config-unicode-pure-php-warning' );
                } else {
@@ -1242,19 +1225,6 @@ abstract class Installer {
         */
        abstract protected function envGetDefaultServer();
 
-       /**
-        * Environment prep for setting the preferred PHP file extension.
-        */
-       protected function envPrepExtension() {
-               // @todo FIXME: Detect this properly
-               if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
-                       $ext = '.php5';
-               } else {
-                       $ext = '.php';
-               }
-               $this->setVar( 'wgScriptExtension', $ext );
-       }
-
        /**
         * Environment prep for setting $IP and $wgScriptPath.
         */
@@ -1304,9 +1274,9 @@ abstract class Installer {
                foreach ( $names as $name ) {
                        $command = $path . DIRECTORY_SEPARATOR . $name;
 
-                       wfSuppressWarnings();
+                       MediaWiki\suppressWarnings();
                        $file_exists = file_exists( $command );
-                       wfRestoreWarnings();
+                       MediaWiki\restoreWarnings();
 
                        if ( $file_exists ) {
                                if ( !$versionInfo ) {
@@ -1364,7 +1334,7 @@ abstract class Installer {
 
                // it would be good to check other popular languages here, but it'll be slow.
 
-               wfSuppressWarnings();
+               MediaWiki\suppressWarnings();
 
                foreach ( $scriptTypes as $ext => $contents ) {
                        foreach ( $contents as $source ) {
@@ -1383,14 +1353,14 @@ abstract class Installer {
                                unlink( $dir . $file );
 
                                if ( $text == 'exec' ) {
-                                       wfRestoreWarnings();
+                                       MediaWiki\restoreWarnings();
 
                                        return $ext;
                                }
                        }
                }
 
-               wfRestoreWarnings();
+               MediaWiki\restoreWarnings();
 
                return false;
        }
@@ -1451,13 +1421,16 @@ abstract class Installer {
                        return array();
                }
 
+               // extensions -> extension.json, skins -> skin.json
+               $jsonFile = substr( $directory, 0, strlen( $directory ) -1 ) . '.json';
+
                $dh = opendir( $extDir );
                $exts = array();
                while ( ( $file = readdir( $dh ) ) !== false ) {
                        if ( !is_dir( "$extDir/$file" ) ) {
                                continue;
                        }
-                       if ( file_exists( "$extDir/$file/$file.php" ) ) {
+                       if ( file_exists( "$extDir/$file/$jsonFile" ) || file_exists( "$extDir/$file/$file.php" ) ) {
                                $exts[] = $file;
                        }
                }
@@ -1504,16 +1477,31 @@ abstract class Installer {
                 */
                global $wgAutoloadClasses;
                $wgAutoloadClasses = array();
+               $queue = array();
 
                require "$IP/includes/DefaultSettings.php";
 
                foreach ( $exts as $e ) {
-                       require_once "$IP/extensions/$e/$e.php";
+                       if ( file_exists( "$IP/extensions/$e/extension.json" ) ) {
+                               $queue["$IP/extensions/$e/extension.json"] = 1;
+                       } else {
+                               require_once "$IP/extensions/$e/$e.php";
+                       }
                }
 
+               $registry = new ExtensionRegistry();
+               $data = $registry->readFromQueue( $queue );
+               $wgAutoloadClasses += $data['autoload'];
+
                $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
                        $wgHooks['LoadExtensionSchemaUpdates'] : array();
 
+               if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
+                       $hooksWeWant = array_merge_recursive(
+                               $hooksWeWant,
+                               $data['globals']['wgHooks']['LoadExtensionSchemaUpdates']
+                       );
+               }
                // Unset everyone else's hooks. Lord knows what someone might be doing
                // in ParserFirstCallInit (see bug 27171)
                $GLOBALS['wgHooks'] = array( 'LoadExtensionSchemaUpdates' => $hooksWeWant );
@@ -1806,8 +1794,8 @@ abstract class Installer {
         * Some long-running pages (Install, Upgrade) will want to do this
         */
        protected function disableTimeLimit() {
-               wfSuppressWarnings();
+               MediaWiki\suppressWarnings();
                set_time_limit( 0 );
-               wfRestoreWarnings();
+               MediaWiki\restoreWarnings();
        }
 }