// 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
*/
protected $settings;
-
/**
* List of detected DBs, access using getCompiledDBs().
*
'mysql',
'postgres',
'oracle',
+ 'mssql',
'sqlite',
);
'envCheckDB',
'envCheckRegisterGlobals',
'envCheckBrokenXML',
- 'envCheckPHP531',
'envCheckMagicQuotes',
'envCheckMagicSybase',
'envCheckMbstring',
- 'envCheckZE1',
'envCheckSafeMode',
'envCheckXML',
'envCheckPCRE',
'envCheckLibicu',
'envCheckSuhosinMaxValueLength',
'envCheckCtype',
+ 'envCheckJSON',
);
/**
'wgImageMagickConvertCommand',
'wgGitBin',
'IP',
- 'wgServer',
'wgScriptPath',
'wgScriptExtension',
'wgMetaNamespace',
/**
* URL to mediawiki-announce subscription
*/
- protected $mediaWikiAnnounceUrl = 'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
+ protected $mediaWikiAnnounceUrl =
+ 'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
/**
* Supported language codes for Mailman
* 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 );
$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();
}
/**
- * 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
*/
require "$IP/includes/DefaultSettings.php";
require "$IP/LocalSettings.php";
- if ( file_exists( "$IP/AdminSettings.php" ) ) {
- require "$IP/AdminSettings.php";
- }
+
return get_defined_vars();
}
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();
}
$databases = $this->getCompiledDBs();
- $databases = array_flip ( $databases );
+ $databases = array_flip( $databases );
foreach ( array_keys( $databases ) as $db ) {
$installer = $this->getDBInstaller( $db );
$status = $installer->checkPrerequisites();
$databases = array_flip( $databases );
if ( !$databases ) {
$this->showError( 'config-no-db', $wgLang->commaList( $allNames ) );
+
// @todo FIXME: This only works for the web installer!
return false;
}
+
return true;
}
$test = new PhpXmlBugTester();
if ( !$test->ok ) {
$this->showError( 'config-brokenlibxml' );
- return false;
- }
- 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;
}
protected function envCheckMagicQuotes() {
if ( wfIniGetBool( "magic_quotes_runtime" ) ) {
$this->showError( 'config-magic-quotes-runtime' );
+
return false;
}
+
return true;
}
protected function envCheckMagicSybase() {
if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
$this->showError( 'config-magic-quotes-sybase' );
+
return false;
}
+
return true;
}
protected function envCheckMbstring() {
if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
$this->showError( 'config-mbstring' );
- return false;
- }
- 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;
}
$this->setVar( '_SafeMode', true );
$this->showMessage( 'config-safe-mode' );
}
+
return true;
}
protected function envCheckXML() {
if ( !function_exists( "utf8_encode" ) ) {
$this->showError( 'config-xml-bad' );
+
return false;
}
+
return true;
}
* @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
wfRestoreWarnings();
if ( $regexd != '--' || $regexprop != '--' ) {
$this->showError( 'config-pcre-no-utf8' );
+
return false;
}
+
return true;
}
$this->setVar( '_RaiseMemory', true );
}
}
+
return true;
}
if ( self::apacheModulePresent( 'mod_security' ) ) {
$this->showMessage( 'config-mod-security' );
}
+
return true;
}
$this->setVar( 'wgDiff3', false );
$this->showMessage( 'config-diff3-bad' );
}
+
return true;
}
if ( $convert ) {
$this->setVar( 'wgImageMagickConvertCommand', $convert );
$this->showMessage( 'config-imagemagick', $convert );
+
return true;
} elseif ( function_exists( 'imagejpeg' ) ) {
$this->showMessage( 'config-gd' );
-
} else {
$this->showMessage( 'config-no-scaling' );
}
+
return true;
}
$this->setVar( 'wgGitBin', false );
$this->showMessage( 'config-git-bad' );
}
+
return true;
}
*/
protected function envCheckServer() {
$server = $this->envGetDefaultServer();
- $this->showMessage( 'config-using-server', $server );
- $this->setVar( 'wgServer', $server );
+ if ( $server !== null ) {
+ $this->showMessage( 'config-using-server', $server );
+ $this->setVar( 'wgServer', $server );
+ }
+
return true;
}
$IP = dirname( dirname( __DIR__ ) );
$this->setVar( 'IP', $IP );
- $this->showMessage( 'config-using-uri', $this->getVar( 'wgServer' ), $this->getVar( 'wgScriptPath' ) );
+ $this->showMessage(
+ 'config-using-uri',
+ $this->getVar( 'wgServer' ),
+ $this->getVar( 'wgScriptPath' )
+ );
+
return true;
}
$ext = 'php';
}
$this->setVar( 'wgScriptExtension', ".$ext" );
+
return true;
}
# Try the current value of LANG.
if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) {
$this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
+
return true;
}
foreach ( $commonLocales as $commonLocale ) {
if ( isset( $candidatesByLocale[$commonLocale] ) ) {
$this->setVar( 'wgShellLocale', $commonLocale );
+
return true;
}
}
if ( isset( $candidatesByLang[$wikiLang] ) ) {
$m = reset( $candidatesByLang[$wikiLang] );
$this->setVar( 'wgShellLocale', $m[0] );
+
return true;
}
if ( count( $candidatesByLocale ) ) {
$m = reset( $candidatesByLocale );
$this->setVar( 'wgShellLocale', $m[0] );
+
return true;
}
if ( !$safe ) {
$this->showMessage( 'config-uploads-not-safe', $dir );
}
+
return true;
}
// Only warn if the value is below the sane 1024
$this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
}
+
return true;
}
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;
}
}
}
- // Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8', 'config-unicode-using-intl'
+ // Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8',
+ // 'config-unicode-using-intl'
if ( $useNormalizer === 'php' ) {
$this->showMessage( 'config-unicode-pure-php-warning' );
} else {
protected function envCheckCtype() {
if ( !function_exists( 'ctype_digit' ) ) {
$this->showError( 'config-ctype' );
+
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @return bool
+ */
+ protected function envCheckJSON() {
+ if ( !function_exists( 'json_decode' ) ) {
+ $this->showError( 'config-json' );
+
return false;
}
+
return true;
}
* @param string $path path to search
* @param array $names of executable names
* @param $versionInfo Boolean false or array with two members:
- * 0 => Command to run for version check, with $1 for the full executable name
- * 1 => String to compare the output with
+ * 0 => Command to run for version check, with $1 for the full executable name
+ * 1 => String to compare the output with
*
* If $versionInfo is not false, only executables with a version
* matching $versionInfo[1] will be returned.
}
}
}
+
return false;
}
/**
* Same as locateExecutable(), but checks in getPossibleBinPaths() by default
* @see locateExecutable()
- * @param $names
- * @param $versionInfo bool
+ * @param array $names Array of possible names.
+ * @param array|bool $versionInfo Default: false or array with two members:
+ * 0 => Command to run for version check, with $1 for the full executable name
+ * 1 => String to compare the output with
+ *
+ * If $versionInfo is not false, only executables with a version
+ * matching $versionInfo[1] will be returned.
* @return bool|string
*/
public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
return $exe;
}
}
+
return false;
}
try {
$text = Http::get( $url . $file, array( 'timeout' => 3 ) );
- }
- catch ( MWException $e ) {
+ } catch ( MWException $e ) {
// Http::get throws with allow_url_fopen = false and no curl extension.
$text = null;
}
if ( $text == 'exec' ) {
wfRestoreWarnings();
+
return $ext;
}
}
ob_start();
phpinfo( INFO_MODULES );
$info = ob_get_clean();
+
return strpos( $info, $moduleName ) !== false;
}
*/
protected function getInstallSteps( DatabaseInstaller $installer ) {
$coreInstallSteps = array(
- array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ),
- array( 'name' => 'tables', 'callback' => array( $installer, 'createTables' ) ),
- array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
- array( 'name' => 'stats', 'callback' => array( $this, 'populateSiteStats' ) ),
- array( 'name' => 'keys', 'callback' => array( $this, 'generateKeys' ) ),
- array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
- array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
+ array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ),
+ array( 'name' => 'tables', 'callback' => array( $installer, 'createTables' ) ),
+ array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
+ array( 'name' => 'stats', 'callback' => array( $this, 'populateSiteStats' ) ),
+ array( 'name' => 'keys', 'callback' => array( $this, 'generateKeys' ) ),
+ array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
+ array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
);
// Build the array of install steps starting from the core install list,
'callback' => array( $installer, 'createExtensionTables' )
);
}
+
return $this->installSteps;
}
if ( $status->isOk() ) {
$this->setVar( '_InstallDone', true );
}
+
return $installResults;
}
if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
$keys['wgUpgradeKey'] = 16;
}
+
return $this->doGenerateKeys( $keys );
}
);
$page->doEditContent( $content,
- '',
- EDIT_NEW,
- false,
- User::newFromName( 'MediaWiki default' ) );
+ '',
+ EDIT_NEW,
+ false,
+ User::newFromName( 'MediaWiki default' )
+ );
} catch ( MWException $e ) {
//using raw, because $wgShowExceptionDetails can not be set yet
$status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
// Some of the environment checks make shell requests, remove limits
$GLOBALS['wgMaxShellMemory'] = 0;
+
+ // Don't bother embedding images into generated CSS, which is not cached
+ $GLOBALS['wgResourceLoaderLESSFunctions']['embeddable'] = function ( $frame, $less ) {
+ return $less->toBool( false );
+ };
}
/**