summaryrefslogtreecommitdiff
path: root/includes/installer/Installer.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/installer/Installer.php')
-rw-r--r--includes/installer/Installer.php98
1 files changed, 78 insertions, 20 deletions
diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php
index 990d4449..ac5dbd74 100644
--- a/includes/installer/Installer.php
+++ b/includes/installer/Installer.php
@@ -2,6 +2,21 @@
/**
* Base code for MediaWiki installer.
*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
* @file
* @ingroup Deployment
*/
@@ -24,7 +39,7 @@
abstract class Installer {
// This is the absolute minimum PHP version we can support
- const MINIMUM_PHP_VERSION = '5.2.3';
+ const MINIMUM_PHP_VERSION = '5.3.2';
/**
* @var array
@@ -293,7 +308,7 @@ abstract class Installer {
/**
* UI interface for displaying a short message
- * The parameters are like parameters to wfMsg().
+ * The parameters are like parameters to wfMessage().
* The messages will be in wikitext format, which will be converted to an
* output format such as HTML or text before being sent to the user.
* @param $msg
@@ -324,7 +339,7 @@ abstract class Installer {
// Load the installer's i18n file.
$wgExtensionMessagesFiles['MediawikiInstaller'] =
- dirname( __FILE__ ) . '/Installer.i18n.php';
+ __DIR__ . '/Installer.i18n.php';
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId( 0 );
@@ -543,7 +558,7 @@ abstract class Installer {
* write your messages. This appears to work well enough. Basic formatting and
* external links work just fine.
*
- * But in case a translator decides to throw in a #ifexist or internal link or
+ * But in case a translator decides to throw in a "#ifexist" or internal link or
* whatever, this function is guarded to catch the attempted DB access and to present
* some fallback text.
*
@@ -630,7 +645,7 @@ abstract class Installer {
$allNames = array();
foreach ( self::getDBTypes() as $name ) {
- $allNames[] = wfMsg( "config-type-$name" );
+ $allNames[] = wfMessage( "config-type-$name" )->text();
}
// cache initially available databases to make sure that everything will be displayed correctly
@@ -659,6 +674,7 @@ abstract class Installer {
return false;
}
$this->setVar( '_CompiledDBs', $databases );
+ return true;
}
/**
@@ -672,6 +688,7 @@ abstract class Installer {
/**
* Some versions of libxml+PHP break < and > encoding horribly
+ * @return bool
*/
protected function envCheckBrokenXML() {
$test = new PhpXmlBugTester();
@@ -679,11 +696,13 @@ abstract class Installer {
$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;
@@ -692,66 +711,79 @@ abstract class Installer {
$this->showError( 'config-using531', phpversion() );
return false;
}
+ return true;
}
/**
* Environment check for magic_quotes_runtime.
+ * @return bool
*/
protected function envCheckMagicQuotes() {
if( wfIniGetBool( "magic_quotes_runtime" ) ) {
$this->showError( 'config-magic-quotes-runtime' );
return false;
}
+ return true;
}
/**
* Environment check for magic_quotes_sybase.
+ * @return bool
*/
protected function envCheckMagicSybase() {
if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
$this->showError( 'config-magic-quotes-sybase' );
return false;
}
+ return true;
}
/**
* Environment check for mbstring.func_overload.
+ * @return bool
*/
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;
}
/**
* Environment check for safe_mode.
+ * @return bool
*/
protected function envCheckSafeMode() {
if ( wfIniGetBool( 'safe_mode' ) ) {
$this->setVar( '_SafeMode', true );
$this->showMessage( 'config-safe-mode' );
}
+ return true;
}
/**
* Environment check for the XML module.
+ * @return bool
*/
protected function envCheckXML() {
if ( !function_exists( "utf8_encode" ) ) {
$this->showError( 'config-xml-bad' );
return false;
}
+ return true;
}
/**
@@ -779,10 +811,12 @@ abstract class Installer {
$this->showError( 'config-pcre-no-utf8' );
return false;
}
+ return true;
}
/**
* Environment check for available memory.
+ * @return bool
*/
protected function envCheckMemory() {
$limit = ini_get( 'memory_limit' );
@@ -802,9 +836,8 @@ abstract class Installer {
$this->showMessage( 'config-memory-raised', $limit, $newLimit );
$this->setVar( '_RaiseMemory', true );
}
- } else {
- return true;
}
+ return true;
}
/**
@@ -830,15 +863,18 @@ abstract class Installer {
/**
* Scare user to death if they have mod_security
+ * @return bool
*/
protected function envCheckModSecurity() {
if ( self::apacheModulePresent( 'mod_security' ) ) {
$this->showMessage( 'config-mod-security' );
}
+ return true;
}
/**
* Search for GNU diff3.
+ * @return bool
*/
protected function envCheckDiff3() {
$names = array( "gdiff3", "diff3", "diff3.exe" );
@@ -852,10 +888,12 @@ abstract class Installer {
$this->setVar( 'wgDiff3', false );
$this->showMessage( 'config-diff3-bad' );
}
+ return true;
}
/**
* Environment check for ImageMagick and GD.
+ * @return bool
*/
protected function envCheckGraphics() {
$names = array( wfIsWindows() ? 'convert.exe' : 'convert' );
@@ -868,10 +906,11 @@ abstract class Installer {
return true;
} elseif ( function_exists( 'imagejpeg' ) ) {
$this->showMessage( 'config-gd' );
- return true;
+
} else {
$this->showMessage( 'config-no-scaling' );
}
+ return true;
}
/**
@@ -881,6 +920,7 @@ abstract class Installer {
$server = $this->envGetDefaultServer();
$this->showMessage( 'config-using-server', $server );
$this->setVar( 'wgServer', $server );
+ return true;
}
/**
@@ -895,7 +935,7 @@ abstract class Installer {
*/
protected function envCheckPath() {
global $IP;
- $IP = dirname( dirname( dirname( __FILE__ ) ) );
+ $IP = dirname( dirname( __DIR__ ) );
$this->setVar( 'IP', $IP );
$this->showMessage( 'config-using-uri', $this->getVar( 'wgServer' ), $this->getVar( 'wgScriptPath' ) );
@@ -913,6 +953,7 @@ abstract class Installer {
$ext = 'php';
}
$this->setVar( 'wgScriptExtension', ".$ext" );
+ return true;
}
/**
@@ -991,6 +1032,7 @@ abstract class Installer {
/**
* TODO: document
+ * @return bool
*/
protected function envCheckUploadsDirectory() {
global $IP;
@@ -999,17 +1041,17 @@ abstract class Installer {
$url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/';
$safe = !$this->dirIsExecutable( $dir, $url );
- if ( $safe ) {
- return true;
- } else {
+ if ( !$safe ) {
$this->showMessage( 'config-uploads-not-safe', $dir );
}
+ return true;
}
/**
* Checks if suhosin.get.max_value_length is set, and if so, sets
* $wgResourceLoaderMaxQueryLength to that value in the generated
* LocalSettings file
+ * @return bool
*/
protected function envCheckSuhosinMaxValueLength() {
$maxValueLength = ini_get( 'suhosin.get.max_value_length' );
@@ -1022,6 +1064,7 @@ abstract class Installer {
$maxValueLength = -1;
}
$this->setVar( 'wgResourceLoaderMaxQueryLength', $maxValueLength );
+ return true;
}
/**
@@ -1075,12 +1118,16 @@ abstract class Installer {
if( $utf8 ) {
$useNormalizer = 'utf8';
$utf8 = utf8_normalize( $not_normal_c, UtfNormal::UNORM_NFC );
- if ( $utf8 !== $normal_c ) $needsUpdate = true;
+ if ( $utf8 !== $normal_c ) {
+ $needsUpdate = true;
+ }
}
if( $intl ) {
$useNormalizer = 'intl';
$intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
- if ( $intl !== $normal_c ) $needsUpdate = true;
+ if ( $intl !== $normal_c ) {
+ $needsUpdate = true;
+ }
}
// Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8', 'config-unicode-using-intl'
@@ -1094,11 +1141,15 @@ abstract class Installer {
}
}
+ /**
+ * @return bool
+ */
protected function envCheckCtype() {
if ( !function_exists( 'ctype_digit' ) ) {
$this->showError( 'config-ctype' );
return false;
}
+ return true;
}
/**
@@ -1131,6 +1182,7 @@ abstract class Installer {
*
* If $versionInfo is not false, only executables with a version
* matching $versionInfo[1] will be returned.
+ * @return bool|string
*/
public static function locateExecutable( $path, $names, $versionInfo = false ) {
if ( !is_array( $names ) ) {
@@ -1179,6 +1231,9 @@ abstract class Installer {
* Checks if scripts located in the given directory can be executed via the given URL.
*
* Used only by environment checks.
+ * @param $dir string
+ * @param $url string
+ * @return bool|int|string
*/
public function dirIsExecutable( $dir, $url ) {
$scriptTypes = array(
@@ -1539,12 +1594,13 @@ abstract class Installer {
$status = Status::newGood();
try {
$page = WikiPage::factory( Title::newMainPage() );
- $page->doEdit( wfMsgForContent( 'mainpagetext' ) . "\n\n" .
- wfMsgForContent( 'mainpagedocfooter' ),
- '',
- EDIT_NEW,
- false,
- User::newFromName( 'MediaWiki default' ) );
+ $page->doEdit( wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
+ wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text(),
+ '',
+ 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() );
@@ -1561,6 +1617,8 @@ abstract class Installer {
// Don't access the database
$GLOBALS['wgUseDatabaseMessages'] = false;
+ // Don't cache langconv tables
+ $GLOBALS['wgLanguageConverterCacheType'] = CACHE_NONE;
// Debug-friendly
$GLOBALS['wgShowExceptionDetails'] = true;
// Don't break forms