From 626addab9ed225790ed7054cbcff039412df1823 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Tue, 8 Oct 2013 13:43:42 +0200 Subject: [PATCH] Update formatting With some manual corrections. Change-Id: Icd947288c32fdb90a0f35388963ef5a17ffa58e7 --- includes/installer/CliInstaller.php | 3 + includes/installer/DatabaseInstaller.php | 19 ++- includes/installer/DatabaseUpdater.php | 42 +++-- includes/installer/InstallDocFormatter.php | 2 + includes/installer/Installer.php | 82 +++++++--- includes/installer/LocalSettingsGenerator.php | 2 +- includes/installer/MysqlInstaller.php | 20 ++- includes/installer/MysqlUpdater.php | 34 ++++- includes/installer/OracleInstaller.php | 12 +- includes/installer/OracleUpdater.php | 2 +- includes/installer/PhpBugTests.php | 2 + includes/installer/PostgresInstaller.php | 21 ++- includes/installer/PostgresUpdater.php | 46 +++--- includes/installer/SqliteInstaller.php | 12 +- includes/installer/SqliteUpdater.php | 3 +- includes/installer/WebInstaller.php | 143 ++++++++++-------- includes/installer/WebInstallerOutput.php | 5 +- includes/installer/WebInstallerPage.php | 110 +++++++++----- 18 files changed, 383 insertions(+), 177 deletions(-) diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index 9f7ed7bc3e..1e6e8c844e 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -168,6 +168,7 @@ class CliInstaller extends Installer { $text = wfMessage( $msg, $params )->parse(); $text = preg_replace( '/(.*?)<\/a>/', '$2 <$1>', $text ); + return html_entity_decode( strip_tags( $text ), ENT_QUOTES ); } @@ -197,6 +198,7 @@ class CliInstaller extends Installer { if ( !$this->specifiedScriptPath ) { $this->showMessage( 'config-no-cli-uri', $this->getVar( "wgScriptPath" ) ); } + return parent::envCheckPath(); } @@ -206,6 +208,7 @@ class CliInstaller extends Installer { public function dirIsExecutable( $dir, $url ) { $this->showMessage( 'config-no-cli-uploads-check', $dir ); + return false; } } diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index ca4ef97792..3739bb5de2 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -158,6 +158,7 @@ abstract class DatabaseInstaller { $this->db->clearFlag( DBO_TRX ); $this->db->commit( __METHOD__ ); } + return $status; } @@ -176,6 +177,7 @@ abstract class DatabaseInstaller { if ( $this->db->tableExists( 'archive', __METHOD__ ) ) { $status->warning( 'config-install-tables-exist' ); $this->enableLB(); + return $status; } @@ -194,6 +196,7 @@ abstract class DatabaseInstaller { if ( $status->isOk() ) { $this->enableLB(); } + return $status; } @@ -279,6 +282,7 @@ abstract class DatabaseInstaller { } $up->purgeCache(); ob_end_flush(); + return $ret; } @@ -288,14 +292,12 @@ abstract class DatabaseInstaller { * long after the constructor. Helpful for things like modifying setup steps :) */ public function preInstall() { - } /** * Allow DB installers a chance to make checks before upgrade. */ public function preUpgrade() { - } /** @@ -327,6 +329,7 @@ abstract class DatabaseInstaller { wfSuppressWarnings(); $compiled = wfDl( $name ); wfRestoreWarnings(); + return $compiled; } @@ -371,6 +374,7 @@ abstract class DatabaseInstaller { } elseif ( isset( $internal[$var] ) ) { $default = $internal[$var]; } + return $this->parent->getVar( $var, $default ); } @@ -398,6 +402,7 @@ abstract class DatabaseInstaller { if ( !isset( $attribs ) ) { $attribs = array(); } + return $this->parent->getTextBox( array( 'var' => $var, 'label' => $label, @@ -424,6 +429,7 @@ abstract class DatabaseInstaller { if ( !isset( $attribs ) ) { $attribs = array(); } + return $this->parent->getPasswordBox( array( 'var' => $var, 'label' => $label, @@ -442,6 +448,7 @@ abstract class DatabaseInstaller { public function getCheckBox( $var, $label, $attribs = array(), $helpData = "" ) { $name = $this->getName() . '_' . $var; $value = $this->getVar( $var ); + return $this->parent->getCheckBox( array( 'var' => $var, 'label' => $label, @@ -449,7 +456,7 @@ abstract class DatabaseInstaller { 'controlName' => $name, 'value' => $value, 'help' => $helpData - )); + ) ); } /** @@ -468,6 +475,7 @@ abstract class DatabaseInstaller { public function getRadioSet( $params ) { $params['controlName'] = $this->getName() . '_' . $params['var']; $params['value'] = $this->getVar( $params['var'] ); + return $this->parent->getRadioSet( $params ); } @@ -501,6 +509,7 @@ abstract class DatabaseInstaller { if ( !$this->db->selectDB( $this->getVar( 'wgDBname' ) ) ) { return false; } + return $this->db->tableExists( 'cur', __METHOD__ ) || $this->db->tableExists( 'revision', __METHOD__ ); } @@ -523,6 +532,7 @@ abstract class DatabaseInstaller { */ public function submitInstallUserBox() { $this->setVarsFromRequest( array( '_InstallUser', '_InstallPassword' ) ); + return Status::newGood(); } @@ -551,6 +561,7 @@ abstract class DatabaseInstaller { $s .= $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create' ); } $s .= Html::closeElement( 'div' ) . Html::closeElement( 'fieldset' ); + return $s; } @@ -590,6 +601,7 @@ abstract class DatabaseInstaller { if ( $this->db->selectRow( 'interwiki', '*', array(), __METHOD__ ) ) { $status->warning( 'config-install-interwiki-exists' ); + return $status; } global $IP; @@ -613,6 +625,7 @@ abstract class DatabaseInstaller { ); } $this->db->insert( 'interwiki', $interwikis, __METHOD__ ); + return Status::newGood(); } diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index d4fe53015f..fdd34d49e3 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -159,6 +159,7 @@ abstract class DatabaseUpdater { $type = $db->getType(); if ( in_array( $type, Installer::getDBTypes() ) ) { $class = ucfirst( $type ) . 'Updater'; + return new $class( $db, $shared, $maintenance ); } else { throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' ); @@ -462,6 +463,7 @@ abstract class DatabaseUpdater { array( 'ul_key' => $key ), __METHOD__ ); + return (bool)$row; } @@ -538,21 +540,21 @@ abstract class DatabaseUpdater { foreach ( $wgExtNewFields as $fieldRecord ) { $updates[] = array( 'addField', $fieldRecord[0], $fieldRecord[1], - $fieldRecord[2], true + $fieldRecord[2], true ); } foreach ( $wgExtNewIndexes as $fieldRecord ) { $updates[] = array( 'addIndex', $fieldRecord[0], $fieldRecord[1], - $fieldRecord[2], true + $fieldRecord[2], true ); } foreach ( $wgExtModifiedFields as $fieldRecord ) { $updates[] = array( 'modifyField', $fieldRecord[0], $fieldRecord[1], - $fieldRecord[2], true + $fieldRecord[2], true ); } @@ -595,6 +597,7 @@ abstract class DatabaseUpdater { if ( fwrite( $this->fileHandle, $line ) === false ) { throw new MWException( "trouble writing file" ); } + return false; } @@ -612,6 +615,7 @@ abstract class DatabaseUpdater { } if ( $this->skipSchema ) { $this->output( "...skipping schema change ($msg).\n" ); + return false; } @@ -626,6 +630,7 @@ abstract class DatabaseUpdater { $this->db->sourceFile( $path ); } $this->output( "done.\n" ); + return true; } @@ -647,6 +652,7 @@ abstract class DatabaseUpdater { } else { return $this->applyPatch( $patch, $fullpath, "Creating $name table" ); } + return true; } @@ -671,6 +677,7 @@ abstract class DatabaseUpdater { } else { return $this->applyPatch( $patch, $fullpath, "Adding $field field to table $table" ); } + return true; } @@ -695,6 +702,7 @@ abstract class DatabaseUpdater { } else { return $this->applyPatch( $patch, $fullpath, "Adding index $index to table $table" ); } + return true; } @@ -717,6 +725,7 @@ abstract class DatabaseUpdater { } else { $this->output( "...$table table does not contain $field field.\n" ); } + return true; } @@ -739,6 +748,7 @@ abstract class DatabaseUpdater { } else { $this->output( "...$index key doesn't exist.\n" ); } + return true; } @@ -761,6 +771,7 @@ abstract class DatabaseUpdater { // First requirement: the table must exist if ( !$this->db->tableExists( $table, __METHOD__ ) ) { $this->output( "...skipping: '$table' table doesn't exist yet.\n" ); + return true; } @@ -771,12 +782,14 @@ abstract class DatabaseUpdater { $this->output( "...WARNING: $oldIndex still exists, despite it has been renamed into $newIndex (which also exists).\n" . " $oldIndex should be manually removed if not needed anymore.\n" ); } + return true; } // Third requirement: the old index must exist if ( !$this->db->indexExists( $table, $oldIndex, __METHOD__ ) ) { $this->output( "...skipping: index $oldIndex doesn't exist.\n" ); + return true; } @@ -807,13 +820,13 @@ abstract class DatabaseUpdater { $this->output( "$msg ..." ); $this->db->dropTable( $table, __METHOD__ ); $this->output( "done.\n" ); - } - else { + } else { return $this->applyPatch( $patch, $fullpath, $msg ); } } else { $this->output( "...$table doesn't exist.\n" ); } + return true; } @@ -840,8 +853,10 @@ abstract class DatabaseUpdater { $this->output( "...$field in table $table already modified by patch $patch.\n" ); } else { $this->insertUpdateRow( $updateKey ); + return $this->applyPatch( $patch, $fullpath, "Modifying $field field of table $table" ); } + return true; } @@ -873,6 +888,7 @@ abstract class DatabaseUpdater { $this->output( "missing ss_total_pages, rebuilding...\n" ); } else { $this->output( "done.\n" ); + return; } SiteStatsInit::doAllAndCommit( $this->db ); @@ -904,9 +920,10 @@ abstract class DatabaseUpdater { protected function doLogUsertextPopulation() { if ( !$this->updateRowExists( 'populate log_usertext' ) ) { $this->output( - "Populating log_user_text field, printing progress markers. For large\n" . - "databases, you may want to hit Ctrl-C and do this manually with\n" . - "maintenance/populateLogUsertext.php.\n" ); + "Populating log_user_text field, printing progress markers. For large\n" . + "databases, you may want to hit Ctrl-C and do this manually with\n" . + "maintenance/populateLogUsertext.php.\n" + ); $task = $this->maintenance->runChild( 'PopulateLogUsertext' ); $task->execute(); @@ -936,6 +953,7 @@ abstract class DatabaseUpdater { protected function doUpdateTranscacheField() { if ( $this->updateRowExists( 'convert transcache field' ) ) { $this->output( "...transcache tc_time already converted.\n" ); + return true; } @@ -954,9 +972,11 @@ abstract class DatabaseUpdater { 'COUNT(*)', 'cl_collation != ' . $this->db->addQuotes( $wgCategoryCollation ), __METHOD__ - ) == 0 ) { - $this->output( "...collations up-to-date.\n" ); - return; + ) == 0 + ) { + $this->output( "...collations up-to-date.\n" ); + + return; } $this->output( "Updating category collations..." ); diff --git a/includes/installer/InstallDocFormatter.php b/includes/installer/InstallDocFormatter.php index ce282cc6f7..0042089a8d 100644 --- a/includes/installer/InstallDocFormatter.php +++ b/includes/installer/InstallDocFormatter.php @@ -23,6 +23,7 @@ class InstallDocFormatter { static function format( $text ) { $obj = new self( $text ); + return $obj->execute(); } @@ -47,6 +48,7 @@ class InstallDocFormatter { $text = preg_replace_callback( '/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text ); // add links to manual to every global variable mentioned $text = preg_replace_callback( '/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text ); + return $text; } diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 1044f18fd6..53ecdb9cdb 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -46,7 +46,6 @@ abstract class Installer { */ protected $settings; - /** * List of detected DBs, access using getCompiledDBs(). * @@ -513,6 +512,7 @@ abstract class Installer { if ( file_exists( "$IP/AdminSettings.php" ) ) { require "$IP/AdminSettings.php"; } + return get_defined_vars(); } @@ -639,6 +639,7 @@ abstract class Installer { 'ss_users' => 0, 'ss_images' => 0 ), __METHOD__, 'IGNORE' ); + return Status::newGood(); } @@ -670,7 +671,7 @@ abstract class Installer { $databases = $this->getCompiledDBs(); - $databases = array_flip ( $databases ); + $databases = array_flip( $databases ); foreach ( array_keys( $databases ) as $db ) { $installer = $this->getDBInstaller( $db ); $status = $installer->checkPrerequisites(); @@ -684,9 +685,11 @@ abstract class Installer { $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; } @@ -707,8 +710,10 @@ abstract class Installer { $test = new PhpXmlBugTester(); if ( !$test->ok ) { $this->showError( 'config-brokenlibxml' ); + return false; } + return true; } @@ -722,8 +727,10 @@ abstract class Installer { $test->execute(); if ( !$test->ok ) { $this->showError( 'config-using531', phpversion() ); + return false; } + return true; } @@ -734,8 +741,10 @@ abstract class Installer { protected function envCheckMagicQuotes() { if ( wfIniGetBool( "magic_quotes_runtime" ) ) { $this->showError( 'config-magic-quotes-runtime' ); + return false; } + return true; } @@ -746,8 +755,10 @@ abstract class Installer { protected function envCheckMagicSybase() { if ( wfIniGetBool( 'magic_quotes_sybase' ) ) { $this->showError( 'config-magic-quotes-sybase' ); + return false; } + return true; } @@ -758,8 +769,10 @@ abstract class Installer { protected function envCheckMbstring() { if ( wfIniGetBool( 'mbstring.func_overload' ) ) { $this->showError( 'config-mbstring' ); + return false; } + return true; } @@ -770,8 +783,10 @@ abstract class Installer { protected function envCheckZE1() { if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) { $this->showError( 'config-ze1' ); + return false; } + return true; } @@ -784,6 +799,7 @@ abstract class Installer { $this->setVar( '_SafeMode', true ); $this->showMessage( 'config-safe-mode' ); } + return true; } @@ -794,8 +810,10 @@ abstract class Installer { protected function envCheckXML() { if ( !function_exists( "utf8_encode" ) ) { $this->showError( 'config-xml-bad' ); + return false; } + return true; } @@ -810,6 +828,7 @@ abstract class Installer { protected function envCheckPCRE() { if ( !function_exists( 'preg_match' ) ) { $this->showError( 'config-pcre' ); + return false; } wfSuppressWarnings(); @@ -822,8 +841,10 @@ abstract class Installer { wfRestoreWarnings(); if ( $regexd != '--' || $regexprop != '--' ) { $this->showError( 'config-pcre-no-utf8' ); + return false; } + return true; } @@ -850,6 +871,7 @@ abstract class Installer { $this->setVar( '_RaiseMemory', true ); } } + return true; } @@ -882,6 +904,7 @@ abstract class Installer { if ( self::apacheModulePresent( 'mod_security' ) ) { $this->showMessage( 'config-mod-security' ); } + return true; } @@ -901,6 +924,7 @@ abstract class Installer { $this->setVar( 'wgDiff3', false ); $this->showMessage( 'config-diff3-bad' ); } + return true; } @@ -917,13 +941,14 @@ abstract class Installer { 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; } @@ -946,6 +971,7 @@ abstract class Installer { $this->setVar( 'wgGitBin', false ); $this->showMessage( 'config-git-bad' ); } + return true; } @@ -956,6 +982,7 @@ abstract class Installer { $server = $this->envGetDefaultServer(); $this->showMessage( 'config-using-server', $server ); $this->setVar( 'wgServer', $server ); + return true; } @@ -975,6 +1002,7 @@ abstract class Installer { $this->setVar( 'IP', $IP ); $this->showMessage( 'config-using-uri', $this->getVar( 'wgServer' ), $this->getVar( 'wgScriptPath' ) ); + return true; } @@ -990,6 +1018,7 @@ abstract class Installer { $ext = 'php'; } $this->setVar( 'wgScriptExtension', ".$ext" ); + return true; } @@ -1035,6 +1064,7 @@ abstract class Installer { # Try the current value of LANG. if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) { $this->setVar( 'wgShellLocale', getenv( 'LANG' ) ); + return true; } @@ -1043,6 +1073,7 @@ abstract class Installer { foreach ( $commonLocales as $commonLocale ) { if ( isset( $candidatesByLocale[$commonLocale] ) ) { $this->setVar( 'wgShellLocale', $commonLocale ); + return true; } } @@ -1053,6 +1084,7 @@ abstract class Installer { if ( isset( $candidatesByLang[$wikiLang] ) ) { $m = reset( $candidatesByLang[$wikiLang] ); $this->setVar( 'wgShellLocale', $m[0] ); + return true; } @@ -1060,6 +1092,7 @@ abstract class Installer { if ( count( $candidatesByLocale ) ) { $m = reset( $candidatesByLocale ); $this->setVar( 'wgShellLocale', $m[0] ); + return true; } @@ -1081,6 +1114,7 @@ abstract class Installer { if ( !$safe ) { $this->showMessage( 'config-uploads-not-safe', $dir ); } + return true; } @@ -1095,6 +1129,7 @@ abstract class Installer { // Only warn if the value is below the sane 1024 $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength ); } + return true; } @@ -1177,8 +1212,10 @@ abstract class Installer { protected function envCheckCtype() { if ( !function_exists( 'ctype_digit' ) ) { $this->showError( 'config-ctype' ); + return false; } + return true; } @@ -1188,8 +1225,10 @@ abstract class Installer { protected function envCheckJSON() { if ( !function_exists( 'json_decode' ) ) { $this->showError( 'config-json' ); + return false; } + return true; } @@ -1218,8 +1257,8 @@ abstract class Installer { * @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. @@ -1248,6 +1287,7 @@ abstract class Installer { } } } + return false; } @@ -1265,6 +1305,7 @@ abstract class Installer { return $exe; } } + return false; } @@ -1298,8 +1339,7 @@ abstract class Installer { 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; } @@ -1307,6 +1347,7 @@ abstract class Installer { if ( $text == 'exec' ) { wfRestoreWarnings(); + return $ext; } } @@ -1331,6 +1372,7 @@ abstract class Installer { ob_start(); phpinfo( INFO_MODULES ); $info = ob_get_clean(); + return strpos( $info, $moduleName ) !== false; } @@ -1436,13 +1478,13 @@ abstract class Installer { */ 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, @@ -1475,6 +1517,7 @@ abstract class Installer { 'callback' => array( $installer, 'createExtensionTables' ) ); } + return $this->installSteps; } @@ -1511,6 +1554,7 @@ abstract class Installer { if ( $status->isOk() ) { $this->setVar( '_InstallDone', true ); } + return $installResults; } @@ -1524,6 +1568,7 @@ abstract class Installer { if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) { $keys['wgUpgradeKey'] = 16; } + return $this->doGenerateKeys( $keys ); } @@ -1645,10 +1690,11 @@ abstract class Installer { ); $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() ); diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index cca8a4a903..dec855e9ce 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -235,6 +235,7 @@ class LocalSettingsGenerator { } $mcservers = $this->buildMemcachedServerList(); + return "fatal( 'config-connection-error', $e->getMessage() ); } + return $status; } @@ -170,6 +171,7 @@ class MysqlInstaller extends DatabaseInstaller { $status = $this->getConnection(); if ( !$status->isOK() ) { $this->parent->showStatusError( $status ); + return; } /** @@ -243,6 +245,7 @@ class MysqlInstaller extends DatabaseInstaller { } } $engines = array_intersect( $this->supportedEngines, $engines ); + return $engines; } @@ -327,6 +330,7 @@ class MysqlInstaller extends DatabaseInstaller { // Can't grant everything return false; } + return true; } @@ -350,7 +354,7 @@ class MysqlInstaller extends DatabaseInstaller { $s .= Xml::openElement( 'div', array( 'id' => 'dbMyisamWarning' - )); + ) ); $myisamWarning = 'config-mysql-myisam-dep'; if ( count( $engines ) === 1 ) { $myisamWarning = 'config-mysql-only-myisam-dep'; @@ -382,7 +386,8 @@ class MysqlInstaller extends DatabaseInstaller { 'class' => 'hideShowRadio', 'rel' => 'dbMyisamWarning' ) - ))); + ) + ) ); $s .= $this->parent->getHelpBox( 'config-mysql-engine-help' ); } @@ -402,7 +407,7 @@ class MysqlInstaller extends DatabaseInstaller { 'label' => 'config-mysql-charset', 'itemLabelPrefix' => 'config-mysql-', 'values' => $charsets - )); + ) ); $s .= $this->parent->getHelpBox( 'config-mysql-charset-help' ); } @@ -454,6 +459,7 @@ class MysqlInstaller extends DatabaseInstaller { if ( !in_array( $this->getVar( '_MysqlCharset' ), $charsets ) ) { $this->setVar( '_MysqlCharset', reset( $charsets ) ); } + return Status::newGood(); } @@ -481,6 +487,7 @@ class MysqlInstaller extends DatabaseInstaller { $conn->selectDB( $dbName ); } $this->setupSchemaVars(); + return $status; } @@ -603,11 +610,11 @@ class MysqlInstaller extends DatabaseInstaller { try { $res = $this->db->selectRow( 'mysql.user', array( 'Host', 'User' ), array( 'Host' => $host, 'User' => $user ), __METHOD__ ); + return (bool)$res; } catch ( DBQueryError $dqe ) { return false; } - } /** @@ -624,6 +631,7 @@ class MysqlInstaller extends DatabaseInstaller { if ( $this->getVar( '_MysqlCharset' ) !== null ) { $options[] = 'DEFAULT CHARSET=' . $this->getVar( '_MysqlCharset' ); } + return implode( ', ', $options ); } @@ -645,8 +653,8 @@ class MysqlInstaller extends DatabaseInstaller { $dbmysql5 = wfBoolToStr( $this->getVar( 'wgDBmysql5', true ) ); $prefix = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgDBprefix' ) ); $tblOpts = LocalSettingsGenerator::escapePhpString( $this->getTableOptions() ); - return -"# MySQL specific settings + + return "# MySQL specific settings \$wgDBprefix = \"{$prefix}\"; # MySQL table options to use during installation or update diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 02faf7c4bb..d92d186826 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -276,11 +276,13 @@ class MysqlUpdater extends DatabaseUpdater { foreach ( $info as $row ) { if ( $row->Column_name == $field ) { $this->output( "...index $index on table $table includes field $field.\n" ); + return true; } } } $this->output( "...index $index on table $table has no field $field; added.\n" ); + return false; } @@ -296,6 +298,7 @@ class MysqlUpdater extends DatabaseUpdater { if ( $this->db->tableExists( "interwiki", __METHOD__ ) ) { $this->output( "...already have interwiki table\n" ); + return; } @@ -313,6 +316,7 @@ class MysqlUpdater extends DatabaseUpdater { } if ( $meta->isMultipleKey() ) { $this->output( "...indexes seem up to 20031107 standards.\n" ); + return; } @@ -328,6 +332,7 @@ class MysqlUpdater extends DatabaseUpdater { $info = $this->db->fieldInfo( 'imagelinks', 'il_from' ); if ( !$info || $info->type() !== 'string' ) { $this->output( "...il_from OK\n" ); + return; } @@ -344,6 +349,7 @@ class MysqlUpdater extends DatabaseUpdater { $nontalk = $this->db->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', __METHOD__ ); if ( $talk == $nontalk ) { $this->output( "...watchlist talk page rows already present.\n" ); + return; } @@ -361,6 +367,7 @@ class MysqlUpdater extends DatabaseUpdater { function doSchemaRestructuring() { if ( $this->db->tableExists( 'page', __METHOD__ ) ) { $this->output( "...page table already exists.\n" ); + return; } @@ -379,7 +386,7 @@ class MysqlUpdater extends DatabaseUpdater { $this->output( sprintf( " %-60s %3s %5s\n", 'Title', 'NS', 'Count' ) ); $duplicate = array(); foreach ( $rows as $row ) { - if ( ! isset( $duplicate[$row->cur_namespace] ) ) { + if ( !isset( $duplicate[$row->cur_namespace] ) ) { $duplicate[$row->cur_namespace] = array(); } $duplicate[$row->cur_namespace][] = $row->cur_title; @@ -552,6 +559,7 @@ class MysqlUpdater extends DatabaseUpdater { protected function doPagelinksUpdate() { if ( $this->db->tableExists( 'pagelinks', __METHOD__ ) ) { $this->output( "...already have pagelinks table.\n" ); + return; } @@ -589,6 +597,7 @@ class MysqlUpdater extends DatabaseUpdater { $duper = new UserDupes( $this->db, array( $this, 'output' ) ); if ( $duper->hasUniqueIndex() ) { $this->output( "...already have unique user_name index.\n" ); + return; } @@ -621,6 +630,7 @@ class MysqlUpdater extends DatabaseUpdater { } else { $this->output( "...user_groups table exists and is in current format.\n" ); } + return; } @@ -633,6 +643,7 @@ class MysqlUpdater extends DatabaseUpdater { $this->output( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" ); $this->output( "*** You may need to manually configure some sysops by manipulating\n" ); $this->output( "*** the user_groups table.\n" ); + return; } } @@ -670,6 +681,7 @@ class MysqlUpdater extends DatabaseUpdater { } if ( $info->isNullable() ) { $this->output( "...wl_notificationtimestamp is already nullable.\n" ); + return; } @@ -696,6 +708,7 @@ class MysqlUpdater extends DatabaseUpdater { protected function doTemplatelinksUpdate() { if ( $this->db->tableExists( 'templatelinks', __METHOD__ ) ) { $this->output( "...templatelinks table already exists\n" ); + return; } @@ -719,7 +732,6 @@ class MysqlUpdater extends DatabaseUpdater { 'tl_title' => $row->pl_title, ), __METHOD__ ); - } } else { // Fast update @@ -739,8 +751,8 @@ class MysqlUpdater extends DatabaseUpdater { protected function doBacklinkingIndicesUpdate() { if ( !$this->indexHasField( 'pagelinks', 'pl_namespace', 'pl_from' ) || !$this->indexHasField( 'templatelinks', 'tl_namespace', 'tl_from' ) || - !$this->indexHasField( 'imagelinks', 'il_to', 'il_from' ) ) - { + !$this->indexHasField( 'imagelinks', 'il_to', 'il_from' ) + ) { $this->applyPatch( 'patch-backlinkindexes.sql', false, "Updating backlinking indices" ); } } @@ -753,6 +765,7 @@ class MysqlUpdater extends DatabaseUpdater { protected function doRestrictionsUpdate() { if ( $this->db->tableExists( 'page_restrictions', __METHOD__ ) ) { $this->output( "...page_restrictions table already exists.\n" ); + return; } @@ -774,6 +787,7 @@ class MysqlUpdater extends DatabaseUpdater { protected function doCategoryPopulation() { if ( $this->updateRowExists( 'populate category' ) ) { $this->output( "...category table already populated.\n" ); + return; } @@ -807,7 +821,7 @@ class MysqlUpdater extends DatabaseUpdater { return true; } - if ( $wgProfileToDatabase === true && ! $this->db->tableExists( 'profiling', __METHOD__ ) ) { + if ( $wgProfileToDatabase === true && !$this->db->tableExists( 'profiling', __METHOD__ ) ) { $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' ); } } @@ -821,8 +835,10 @@ class MysqlUpdater extends DatabaseUpdater { return true; } elseif ( $this->db->fieldExists( 'profiling', 'pf_memory', __METHOD__ ) ) { $this->output( "...profiling table has pf_memory field.\n" ); + return true; } + return $this->applyPatch( 'patch-profiling-memory.sql', false, "Adding pf_memory field to table profiling" ); } @@ -831,6 +847,7 @@ class MysqlUpdater extends DatabaseUpdater { if ( !$info ) { $this->applyPatch( 'patch-filearchive-user-index.sql', false, "Updating filearchive indices" ); } + return true; } @@ -838,10 +855,12 @@ class MysqlUpdater extends DatabaseUpdater { $info = $this->db->indexInfo( 'pagelinks', 'pl_namespace' ); if ( is_array( $info ) && !$info[0]->Non_unique ) { $this->output( "...pl_namespace, tl_namespace, il_to indices are already UNIQUE.\n" ); + return true; } if ( $this->skipSchema ) { $this->output( "...skipping schema change (making pl_namespace, tl_namespace and il_to indices UNIQUE).\n" ); + return false; } @@ -851,6 +870,7 @@ class MysqlUpdater extends DatabaseUpdater { protected function doUpdateMimeMinorField() { if ( $this->updateRowExists( 'mime_minor_length' ) ) { $this->output( "...*_mime_minor fields are already long enough.\n" ); + return; } @@ -860,6 +880,7 @@ class MysqlUpdater extends DatabaseUpdater { protected function doClFieldsUpdate() { if ( $this->updateRowExists( 'cl_fields_update' ) ) { $this->output( "...categorylinks up-to-date.\n" ); + return; } @@ -889,6 +910,7 @@ class MysqlUpdater extends DatabaseUpdater { } if ( $info->isNullable() ) { $this->output( "...user_last_timestamp is already nullable.\n" ); + return; } @@ -899,10 +921,12 @@ class MysqlUpdater extends DatabaseUpdater { $info = $this->db->indexInfo( 'iwlinks', 'iwl_prefix_title_from' ); if ( is_array( $info ) && $info[0]->Non_unique ) { $this->output( "...iwl_prefix_title_from index is already non-UNIQUE.\n" ); + return true; } if ( $this->skipSchema ) { $this->output( "...skipping schema change (making iwl_prefix_title_from index non-UNIQUE).\n" ); + return false; } diff --git a/includes/installer/OracleInstaller.php b/includes/installer/OracleInstaller.php index aa950938a7..efa8d007b8 100644 --- a/includes/installer/OracleInstaller.php +++ b/includes/installer/OracleInstaller.php @@ -59,6 +59,7 @@ class OracleInstaller extends DatabaseInstaller { if ( $this->getVar( 'wgDBserver' ) == 'localhost' ) { $this->parent->setVar( 'wgDBserver', '' ); } + return $this->getTextBox( 'wgDBserver', 'config-db-host-oracle', array(), $this->parent->getHelpBox( 'config-db-host-oracle-help' ) ) . Html::openElement( 'fieldset' ) . Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) . @@ -74,6 +75,7 @@ class OracleInstaller extends DatabaseInstaller { public function submitInstallUserBox() { parent::submitInstallUserBox(); $this->parent->setVar( '_InstallDBname', $this->getVar( '_InstallUser' ) ); + return Status::newGood(); } @@ -162,6 +164,7 @@ class OracleInstaller extends DatabaseInstaller { $this->connError = $e->db->lastErrno(); $status->fatal( 'config-connection-error', $e->getMessage() ); } + return $status; } @@ -181,6 +184,7 @@ class OracleInstaller extends DatabaseInstaller { $this->connError = $e->db->lastErrno(); $status->fatal( 'config-connection-error', $e->getMessage() ); } + return $status; } @@ -189,6 +193,7 @@ class OracleInstaller extends DatabaseInstaller { $this->parent->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) ); $retVal = parent::needsUpgrade(); $this->parent->setVar( 'wgDBname', $tempDBname ); + return $retVal; } @@ -203,6 +208,7 @@ class OracleInstaller extends DatabaseInstaller { public function setupDatabase() { $status = Status::newGood(); + return $status; } @@ -285,13 +291,14 @@ class OracleInstaller extends DatabaseInstaller { foreach ( $varNames as $name ) { $vars[$name] = $this->getVar( $name ); } + return $vars; } public function getLocalSettings() { $prefix = $this->getVar( 'wgDBprefix' ); - return -"# Oracle specific settings + + return "# Oracle specific settings \$wgDBprefix = \"{$prefix}\"; "; } @@ -315,5 +322,4 @@ class OracleInstaller extends DatabaseInstaller { $isValid |= preg_match( '/^(?:\/\/)?[\w\-\.]+(?::[\d]+)?(?:\/(?:[\w\-\.]+(?::(pooled|dedicated|shared))?)?(?:\/[\w\-\.]+)?)?$/', $connect_string ); // EZConnect return (bool)$isValid; } - } diff --git a/includes/installer/OracleUpdater.php b/includes/installer/OracleUpdater.php index be10e04531..f3f86ebcf3 100644 --- a/includes/installer/OracleUpdater.php +++ b/includes/installer/OracleUpdater.php @@ -212,6 +212,7 @@ class OracleUpdater extends DatabaseUpdater { $row = $meta->fetchRow(); if ( $row['column_name'] == 'PR_ID' ) { $this->output( "seems to be up to date.\n" ); + return; } @@ -247,5 +248,4 @@ class OracleUpdater extends DatabaseUpdater { $this->db->delete( '/*Q*/' . $this->db->tableName( 'objectcache' ), '*', __METHOD__ ); $this->output( "done.\n" ); } - } diff --git a/includes/installer/PhpBugTests.php b/includes/installer/PhpBugTests.php index 773debe0f2..5471264468 100644 --- a/includes/installer/PhpBugTests.php +++ b/includes/installer/PhpBugTests.php @@ -30,6 +30,7 @@ class PhpXmlBugTester { private $parsedData = ''; public $ok = false; + public function __construct() { $charData = 'c'; $xml = '' . htmlspecialchars( $charData ) . ''; @@ -39,6 +40,7 @@ class PhpXmlBugTester { $parsedOk = xml_parse( $parser, $xml, true ); $this->ok = $parsedOk && ( $this->parsedData == $charData ); } + public function chardata( $parser, $data ) { $this->parsedData .= $data; } diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index 37471890b4..a7e84629db 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -107,6 +107,7 @@ class PostgresInstaller extends DatabaseInstaller { $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) ); $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) ); + return Status::newGood(); } @@ -115,6 +116,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( $status->isOK() ) { $this->db = $status->value; } + return $status; } @@ -142,6 +144,7 @@ class PostgresInstaller extends DatabaseInstaller { } catch ( DBConnectionError $e ) { $status->fatal( 'config-connection-error', $e->getMessage() ); } + return $status; } @@ -165,6 +168,7 @@ class PostgresInstaller extends DatabaseInstaller { $conn->commit( __METHOD__ ); $this->pgConns[$type] = $conn; } + return $status; } @@ -215,6 +219,7 @@ class PostgresInstaller extends DatabaseInstaller { $safeRole = $conn->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) ); $conn->query( "SET ROLE $safeRole" ); } + return $status; default: throw new MWException( "Invalid special connection type: \"$type\"" ); @@ -267,6 +272,7 @@ class PostgresInstaller extends DatabaseInstaller { $row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*', array( 'rolname' => $superuser ), __METHOD__ ); + return $row; } @@ -275,6 +281,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( !$perms ) { return false; } + return $perms->rolsuper === 't' || $perms->rolcreaterole === 't'; } @@ -283,6 +290,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( !$perms ) { return false; } + return $perms->rolsuper === 't'; } @@ -331,6 +339,7 @@ class PostgresInstaller extends DatabaseInstaller { } else { $msg = 'config-install-user-missing'; } + return Status::newFatal( $msg, $this->getVar( 'wgDBuser' ) ); } @@ -410,6 +419,7 @@ class PostgresInstaller extends DatabaseInstaller { } } } + return false; } @@ -454,6 +464,7 @@ class PostgresInstaller extends DatabaseInstaller { $safedb = $conn->addIdentifierQuotes( $dbName ); $conn->query( "CREATE DATABASE $safedb", __METHOD__ ); } + return Status::newGood(); } @@ -480,11 +491,13 @@ class PostgresInstaller extends DatabaseInstaller { // Select the new schema in the current connection $conn->determineCoreSchema( $schema ); + return Status::newGood(); } function commitChanges() { $this->db->commit( __METHOD__ ); + return Status::newGood(); } @@ -529,8 +542,8 @@ class PostgresInstaller extends DatabaseInstaller { function getLocalSettings() { $port = $this->getVar( 'wgDBport' ); $schema = $this->getVar( 'wgDBmwschema' ); - return -"# Postgres specific settings + + return "# Postgres specific settings \$wgDBport = \"{$port}\"; \$wgDBmwschema = \"{$schema}\";"; } @@ -560,6 +573,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( $conn->tableExists( 'archive' ) ) { $status->warning( 'config-install-tables-exist' ); $this->enableLB(); + return $status; } @@ -567,6 +581,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( !$conn->schemaExists( $schema ) ) { $status->fatal( 'config-install-pg-schema-not-exist' ); + return $status; } $error = $conn->sourceFile( $conn->getSchemaPath() ); @@ -581,6 +596,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( $status->isOk() ) { $this->enableLB(); } + return $status; } @@ -623,6 +639,7 @@ class PostgresInstaller extends DatabaseInstaller { } else { return Status::newFatal( 'config-pg-no-plpgsql', $this->getVar( 'wgDBname' ) ); } + return Status::newGood(); } } diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 58a54c4219..a4c9d74515 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -371,25 +371,25 @@ class PostgresUpdater extends DatabaseUpdater { # Add missing extension fields foreach ( $wgExtPGNewFields as $fieldRecord ) { $updates[] = array( - 'addPgField', $fieldRecord[0], $fieldRecord[1], - $fieldRecord[2] - ); + 'addPgField', $fieldRecord[0], $fieldRecord[1], + $fieldRecord[2] + ); } # Change altered columns foreach ( $wgExtPGAlteredFields as $fieldRecord ) { $updates[] = array( - 'changeField', $fieldRecord[0], $fieldRecord[1], - $fieldRecord[2] - ); + 'changeField', $fieldRecord[0], $fieldRecord[1], + $fieldRecord[2] + ); } # Add missing extension indexes foreach ( $wgExtNewIndexes as $fieldRecord ) { $updates[] = array( - 'addPgExtIndex', $fieldRecord[0], $fieldRecord[1], - $fieldRecord[2] - ); + 'addPgExtIndex', $fieldRecord[0], $fieldRecord[1], + $fieldRecord[2] + ); } return $updates; @@ -403,8 +403,8 @@ SELECT attname, attnum FROM pg_namespace, pg_class, pg_attribute AND relname=%s AND nspname=%s END; $res = $this->db->query( sprintf( $q, - $this->db->addQuotes( $table ), - $this->db->addQuotes( $this->db->getCoreSchema() ) ) ); + $this->db->addQuotes( $table ), + $this->db->addQuotes( $this->db->getCoreSchema() ) ) ); if ( !$res ) { return null; } @@ -412,10 +412,11 @@ END; $cols = array(); foreach ( $res as $r ) { $cols[] = array( - "name" => $r[0], - "ord" => $r[1], - ); + "name" => $r[0], + "ord" => $r[1], + ); } + return $cols; } @@ -485,11 +486,12 @@ END; if ( !( $row = $this->db->fetchRow( $r ) ) ) { return null; } + return $row[0]; } function ruleDef( $table, $rule ) { - $q = <<db->sequenceExists( $new ) ) { $this->output( "...sequence $new already exists.\n" ); + return; } if ( $this->db->sequenceExists( $old ) ) { @@ -550,6 +554,7 @@ END; // First requirement: the table must exist if ( !$this->db->tableExists( $table, __METHOD__ ) ) { $this->output( "...skipping: '$table' table doesn't exist yet.\n" ); + return; } @@ -557,17 +562,19 @@ END; if ( $this->db->indexExists( $table, $new, __METHOD__ ) ) { $this->output( "...index $new already set on $table table.\n" ); if ( !$skipBothIndexExistWarning - && $this->db->indexExists( $table, $old, __METHOD__ ) ) - { + && $this->db->indexExists( $table, $old, __METHOD__ ) + ) { $this->output( "...WARNING: $old still exists, despite it has been renamed into $new (which also exists).\n" . " $old should be manually removed if not needed anymore.\n" ); } + return; } // Third requirement: the old index must exist if ( !$this->db->indexExists( $table, $old, __METHOD__ ) ) { $this->output( "...skipping: index $old doesn't exist.\n" ); + return; } @@ -578,6 +585,7 @@ END; $fi = $this->db->fieldInfo( $table, $field ); if ( !is_null( $fi ) ) { $this->output( "...column '$table.$field' already exists\n" ); + return; } else { $this->output( "Adding column '$table.$field'\n" ); @@ -638,8 +646,7 @@ END; if ( 'NULL' === $null ) { $this->output( "Changing '$table.$field' to allow NULLs\n" ); $this->db->query( "ALTER TABLE $table ALTER $field DROP NOT NULL" ); - } - else { + } else { $this->output( "...column '$table.$field' is already set as NOT NULL\n" ); } } @@ -671,6 +678,7 @@ END; $fi = $this->db->fieldInfo( $table, $field ); if ( is_null( $fi ) ) { $this->output( "WARNING! Column '$table.$field' does not exist but it should! Please report this.\n" ); + return; } if ( $fi->is_deferred() && $fi->is_deferrable() ) { diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index 50a7181864..136ca4b560 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -63,6 +63,7 @@ class SqliteInstaller extends DatabaseInstaller { if ( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) { $result->warning( 'config-no-fts3' ); } + return $result; } @@ -73,6 +74,7 @@ class SqliteInstaller extends DatabaseInstaller { DIRECTORY_SEPARATOR, dirname( $_SERVER['DOCUMENT_ROOT'] ) . '/data' ); + return array( 'wgSQLiteDataDir' => $path ); } else { return array(); @@ -96,6 +98,7 @@ class SqliteInstaller extends DatabaseInstaller { if ( !$result ) { return $path; } + return $result; } @@ -115,6 +118,7 @@ class SqliteInstaller extends DatabaseInstaller { } # Table prefix is not used on SQLite, keep it empty $this->setVar( 'wgDBprefix', '' ); + return $result; } @@ -173,6 +177,7 @@ class SqliteInstaller extends DatabaseInstaller { } catch ( DBConnectionError $e ) { $status->fatal( 'config-sqlite-connection-error', $e->getMessage() ); } + return $status; } @@ -220,6 +225,7 @@ class SqliteInstaller extends DatabaseInstaller { $this->setVar( 'wgDBuser', '' ); $this->setVar( 'wgDBpassword', '' ); $this->setupSchemaVars(); + return $this->getConnection(); } @@ -228,6 +234,7 @@ class SqliteInstaller extends DatabaseInstaller { */ public function createTables() { $status = parent::createTables(); + return $this->setupSearchIndex( $status ); } @@ -246,6 +253,7 @@ class SqliteInstaller extends DatabaseInstaller { } elseif ( !$fts3tTable && $module == 'FTS3' ) { $this->db->sourceFile( "$IP/maintenance/sqlite/archives/searchindex-fts3.sql" ); } + return $status; } @@ -254,8 +262,8 @@ class SqliteInstaller extends DatabaseInstaller { */ public function getLocalSettings() { $dir = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgSQLiteDataDir' ) ); - return -"# SQLite-specific settings + + return "# SQLite-specific settings \$wgSQLiteDataDir = \"{$dir}\";"; } } diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index 28d8d66b1b..df69c0e051 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -116,6 +116,7 @@ class SqliteUpdater extends DatabaseUpdater { // initial-indexes.sql fails if the indexes are already present, so we perform a quick check if our database is newer. if ( $this->updateRowExists( 'initial_indexes' ) || $this->db->indexExists( 'user', 'user_name', __METHOD__ ) ) { $this->output( "...have initial indexes\n" ); + return; } $this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" ); @@ -135,7 +136,7 @@ class SqliteUpdater extends DatabaseUpdater { protected function doEnableProfiling() { global $wgProfileToDatabase; - if ( $wgProfileToDatabase === true && ! $this->db->tableExists( 'profiling', __METHOD__ ) ) { + if ( $wgProfileToDatabase === true && !$this->db->tableExists( 'profiling', __METHOD__ ) ) { $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' ); } } diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 9fcd312930..cbceed6e10 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -155,8 +155,8 @@ class WebInstaller extends Installer { $this->setupLanguage(); if ( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) ) - && $this->request->getVal( 'localsettings' ) ) - { + && $this->request->getVal( 'localsettings' ) + ) { $this->request->response()->header( 'Content-type: application/x-httpd-php' ); $this->request->response()->header( 'Content-Disposition: attachment; filename="LocalSettings.php"' @@ -168,6 +168,7 @@ class WebInstaller extends Installer { $ls->setGroupRights( $group, $rightsArr ); } echo $ls->getText(); + return $this->session; } @@ -176,6 +177,7 @@ class WebInstaller extends Installer { $cssDir = ( $cssDir == 'rtl' ? 'rtl' : 'ltr' ); $this->request->response()->header( 'Content-type: text/css' ); echo $this->output->getCSS( $cssDir ); + return $this->session; } @@ -199,6 +201,7 @@ class WebInstaller extends Installer { $this->output->useShortHeader(); $this->output->allowFrames(); $page->submitCC(); + return $this->finish(); } @@ -207,6 +210,7 @@ class WebInstaller extends Installer { $this->output->useShortHeader(); $this->output->allowFrames(); $this->output->addHTML( $page->getCCDoneBox() ); + return $this->finish(); } @@ -256,6 +260,7 @@ class WebInstaller extends Installer { } $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) ); + return $this->finish(); } @@ -336,6 +341,7 @@ class WebInstaller extends Installer { if ( $this->phpErrors ) { $this->showError( 'config-session-error', $this->phpErrors[0] ); + return false; } @@ -362,6 +368,7 @@ class WebInstaller extends Installer { // the /mw-config/index.php. Kinda scary though? $url = $m[1]; } + return md5( serialize( array( 'local path' => dirname( __DIR__ ), 'url' => $url, @@ -614,9 +621,9 @@ class WebInstaller extends Installer { */ private function endPageWrapper() { $this->output->addHTMLNoFlush( - "
\n" . - "\n" . - "
\n" . + "
\n" . + "\n" . + "
\n" . "" ); } @@ -655,6 +662,7 @@ class WebInstaller extends Installer { $text = $this->parse( $text, true ); $icon = ( $icon == false ) ? '../skins/common/images/info-32.png' : '../skins/common/images/' . $icon; $alt = wfMessage( 'config-information' )->text(); + return Html::infoBox( $text, $icon, $alt, $class, false ); } @@ -699,7 +707,7 @@ class WebInstaller extends Installer { $args = func_get_args(); array_shift( $args ); $html = '
' . - $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) . + $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) . "
\n"; $this->output->addHTML( $html ); } @@ -741,11 +749,12 @@ class WebInstaller extends Installer { "
\n" . Xml::tags( 'label', $attributes, - $labelText ) . "\n" . - $helpData . + $labelText + ) . "\n" . + $helpData . "
\n" . "
\n" . - $contents . + $contents . "
\n" . "\n"; } @@ -755,12 +764,12 @@ class WebInstaller extends Installer { * * @param $params Array * Parameters are: - * var: The variable to be configured (required) - * label: The message name for the label (required) - * attribs: Additional attributes for the input element (optional) + * var: The variable to be configured (required) + * label: The message name for the label (required) + * attribs: Additional attributes for the input element (optional) * controlName: The name for the input element (optional) - * value: The current value of the variable (optional) - * help: The html for the help text (optional) + * value: The current value of the variable (optional) + * help: The html for the help text (optional) * * @return string */ @@ -779,21 +788,22 @@ class WebInstaller extends Installer { if ( !isset( $params['help'] ) ) { $params['help'] = ""; } + return $this->label( - $params['label'], + $params['label'], + $params['controlName'], + Xml::input( $params['controlName'], - Xml::input( - $params['controlName'], - 30, // intended to be overridden by CSS - $params['value'], - $params['attribs'] + array( - 'id' => $params['controlName'], - 'class' => 'config-input-text', - 'tabindex' => $this->nextTabIndex() - ) - ), - $params['help'] - ); + 30, // intended to be overridden by CSS + $params['value'], + $params['attribs'] + array( + 'id' => $params['controlName'], + 'class' => 'config-input-text', + 'tabindex' => $this->nextTabIndex() + ) + ), + $params['help'] + ); } /** @@ -801,12 +811,12 @@ class WebInstaller extends Installer { * * @param $params Array * Parameters are: - * var: The variable to be configured (required) - * label: The message name for the label (required) - * attribs: Additional attributes for the input element (optional) + * var: The variable to be configured (required) + * label: The message name for the label (required) + * attribs: Additional attributes for the input element (optional) * controlName: The name for the input element (optional) - * value: The current value of the variable (optional) - * help: The html for the help text (optional) + * value: The current value of the variable (optional) + * help: The html for the help text (optional) * * @return string */ @@ -825,22 +835,23 @@ class WebInstaller extends Installer { if ( !isset( $params['help'] ) ) { $params['help'] = ""; } + return $this->label( - $params['label'], + $params['label'], + $params['controlName'], + Xml::textarea( $params['controlName'], - Xml::textarea( - $params['controlName'], - $params['value'], - 30, - 5, - $params['attribs'] + array( - 'id' => $params['controlName'], - 'class' => 'config-input-text', - 'tabindex' => $this->nextTabIndex() - ) - ), - $params['help'] - ); + $params['value'], + 30, + 5, + $params['attribs'] + array( + 'id' => $params['controlName'], + 'class' => 'config-input-text', + 'tabindex' => $this->nextTabIndex() + ) + ), + $params['help'] + ); } /** @@ -849,12 +860,12 @@ class WebInstaller extends Installer { * Implements password hiding * @param $params Array * Parameters are: - * var: The variable to be configured (required) - * label: The message name for the label (required) - * attribs: Additional attributes for the input element (optional) + * var: The variable to be configured (required) + * label: The message name for the label (required) + * attribs: Additional attributes for the input element (optional) * controlName: The name for the input element (optional) - * value: The current value of the variable (optional) - * help: The html for the help text (optional) + * value: The current value of the variable (optional) + * help: The html for the help text (optional) * * @return string */ @@ -878,12 +889,12 @@ class WebInstaller extends Installer { * * @param $params Array * Parameters are: - * var: The variable to be configured (required) - * label: The message name for the label (required) - * attribs: Additional attributes for the input element (optional) + * var: The variable to be configured (required) + * label: The message name for the label (required) + * attribs: Additional attributes for the input element (optional) * controlName: The name for the input element (optional) - * value: The current value of the variable (optional) - * help: The html for the help text (optional) + * value: The current value of the variable (optional) + * help: The html for the help text (optional) * * @return string */ @@ -929,15 +940,15 @@ class WebInstaller extends Installer { * * @param $params Array * Parameters are: - * var: The variable to be configured (required) - * label: The message name for the label (required) + * var: The variable to be configured (required) + * label: The message name for the label (required) * itemLabelPrefix: The message name prefix for the item labels (required) - * values: List of allowed values (required) - * itemAttribs Array of attribute arrays, outer key is the value name (optional) - * commonAttribs Attribute array applied to all items - * controlName: The name for the input element (optional) - * value: The current value of the variable (optional) - * help: The html for the help text (optional) + * values: List of allowed values (required) + * itemAttribs: Array of attribute arrays, outer key is the value name (optional) + * commonAttribs: Attribute array applied to all items + * controlName: The name for the input element (optional) + * value: The current value of the variable (optional) + * help: The html for the help text (optional) * * @return string */ @@ -1067,6 +1078,7 @@ class WebInstaller extends Installer { */ public function docLink( $linkText, $attribs, $parser ) { $url = $this->getDocUrl( $attribs['href'] ); + return '' . htmlspecialchars( $linkText ) . ''; @@ -1089,6 +1101,7 @@ class WebInstaller extends Installer { $anchor = Html::rawElement( 'a', array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ), $img . ' ' . wfMessage( 'config-download-localsettings' )->parse() ); + return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor ); } @@ -1110,8 +1123,10 @@ class WebInstaller extends Installer { $this->setVar( 'wgScriptPath', $uri ); } else { $this->showError( 'config-no-uri' ); + return false; } + return parent::envCheckPath(); } diff --git a/includes/installer/WebInstallerOutput.php b/includes/installer/WebInstallerOutput.php index 77e9a2cb04..79dc80fe5b 100644 --- a/includes/installer/WebInstallerOutput.php +++ b/includes/installer/WebInstallerOutput.php @@ -185,6 +185,7 @@ class WebInstallerOutput { */ public function getDir() { global $wgLang; + return is_object( $wgLang ) ? $wgLang->getDir() : 'ltr'; } @@ -193,6 +194,7 @@ class WebInstallerOutput { */ public function getLanguageCode() { global $wgLang; + return is_object( $wgLang ) ? $wgLang->getCode() : 'en'; } @@ -224,14 +226,15 @@ class WebInstallerOutput { } if ( $this->redirectTarget ) { $this->parent->request->response()->header( 'Location: ' . $this->redirectTarget ); + return; } if ( $this->useShortHeader ) { $this->outputShortHeader(); + return; } - ?> getHeadAttribs() ); ?> diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index 510ea6c6bb..11c0a8ee68 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -89,27 +89,35 @@ abstract class WebInstallerPage { if ( $continue ) { // Fake submit button for enter keypress (bug 26267) // Messages: config-continue, config-restart, config-regenerate - $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(), - array( 'name' => "enter-$continue", 'style' => - 'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n"; + $s .= Xml::submitButton( + wfMessage( "config-$continue" )->text(), + array( + 'name' => "enter-$continue", + 'style' => 'visibility:hidden;overflow:hidden;width:1px;margin:0' + ) + ) . "\n"; } if ( $back ) { // Message: config-back - $s .= Xml::submitButton( wfMessage( "config-$back" )->text(), + $s .= Xml::submitButton( + wfMessage( "config-$back" )->text(), array( 'name' => "submit-$back", 'tabindex' => $this->parent->nextTabIndex() - ) ) . "\n"; + ) + ) . "\n"; } if ( $continue ) { // Messages: config-continue, config-restart, config-regenerate - $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(), + $s .= Xml::submitButton( + wfMessage( "config-$continue" )->text(), array( 'name' => "submit-$continue", 'tabindex' => $this->parent->nextTabIndex(), - ) ) . "\n"; + ) + ) . "\n"; } $s .= "\n"; @@ -211,6 +219,7 @@ class WebInstaller_Language extends WebInstallerPage { if ( isset( $languages[$contLang] ) ) { $this->setVar( 'wgLanguageCode', $contLang ); } + return 'continue'; } } elseif ( $this->parent->showSessionWarning ) { @@ -264,9 +273,9 @@ class WebInstaller_Language extends WebInstallerPage { $s .= "\n" . Xml::option( "$code - $lang", $code, $code == $selectedCode ); } $s .= "\n\n"; + return $this->parent->label( $label, $name, $s ); } - } class WebInstaller_ExistingWiki extends WebInstallerPage { @@ -280,8 +289,8 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { // Check if the upgrade key supplied to the user has appeared in LocalSettings.php if ( $vars['wgUpgradeKey'] !== false && $this->getVar( '_UpgradeKeySupplied' ) - && $this->getVar( 'wgUpgradeKey' ) === $vars['wgUpgradeKey'] ) - { + && $this->getVar( 'wgUpgradeKey' ) === $vars['wgUpgradeKey'] + ) { // It's there, so the user is authorized $status = $this->handleExistingUpgrade( $vars ); if ( $status->isOK() ) { @@ -290,6 +299,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { $this->startForm(); $this->parent->showStatusBox( $status ); $this->endForm( 'continue' ); + return 'output'; } } @@ -308,6 +318,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { $this->getVar( 'wgUpgradeKey' ) . "';" )->plain() ) ); $this->endForm( 'continue' ); + return 'output'; } @@ -319,6 +330,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { if ( !$key || $key !== $vars['wgUpgradeKey'] ) { $this->parent->showError( 'config-localsettings-badkey' ); $this->showKeyForm(); + return 'output'; } // Key was OK @@ -328,10 +340,12 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { } else { $this->parent->showStatusBox( $status ); $this->showKeyForm(); + return 'output'; } } else { $this->showKeyForm(); + return 'output'; } } @@ -361,6 +375,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { } $this->setVar( $name, $vars[$name] ); } + return $status; } @@ -372,7 +387,8 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { protected function handleExistingUpgrade( $vars ) { // Check $wgDBtype if ( !isset( $vars['wgDBtype'] ) || - !in_array( $vars['wgDBtype'], Installer::getDBTypes() ) ) { + !in_array( $vars['wgDBtype'], Installer::getDBTypes() ) + ) { return Status::newFatal( 'config-localsettings-connection-error', '' ); } @@ -402,11 +418,13 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { // Adjust the error message to explain things correctly $status->replaceMessage( 'config-connection-error', 'config-localsettings-connection-error' ); + return $status; } // All good $this->setVar( '_ExistingDBSettings', true ); + return $status; } } @@ -431,9 +449,9 @@ class WebInstaller_Welcome extends WebInstallerPage { } else { $this->parent->showStatusMessage( $status ); } + return ''; } - } class WebInstaller_DBConnect extends WebInstallerPage { @@ -449,6 +467,7 @@ class WebInstaller_DBConnect extends WebInstallerPage { if ( $status->isGood() ) { $this->setVar( '_UpgradeDone', false ); + return 'continue'; } else { $this->parent->showStatusBox( $status ); @@ -494,20 +513,21 @@ class WebInstaller_DBConnect extends WebInstallerPage { // Messages: config-header-mysql, config-header-postgres, config-header-oracle, // config-header-sqlite - $settings .= - Html::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, - 'class' => 'dbWrapper' ) ) . + $settings .= Html::openElement( + 'div', + array( + 'id' => 'DB_wrapper_' . $type, + 'class' => 'dbWrapper' + ) + ) . Html::element( 'h3', array(), wfMessage( 'config-header-' . $type )->text() ) . $installer->getConnectForm() . "\n"; } - $types .= "
\n"; - $this->addHTML( - $this->parent->label( 'config-db-type', false, $types ) . - $settings - ); + $types .= "
\n"; + $this->addHTML( $this->parent->label( 'config-db-type', false, $types ) . $settings ); $this->endForm(); } @@ -522,9 +542,9 @@ class WebInstaller_DBConnect extends WebInstallerPage { if ( !$installer ) { return Status::newFatal( 'config-invalid-db-type' ); } + return $installer->submitConnectForm(); } - } class WebInstaller_Upgrade extends WebInstallerPage { @@ -545,6 +565,7 @@ class WebInstaller_Upgrade extends WebInstallerPage { // Show the done message again // Make them click back again if they want to do the upgrade again $this->showDoneMessage(); + return 'output'; } } @@ -573,6 +594,7 @@ class WebInstaller_Upgrade extends WebInstallerPage { } $this->setVar( '_UpgradeDone', true ); $this->showDoneMessage(); + return 'output'; } } @@ -596,15 +618,14 @@ class WebInstaller_Upgrade extends WebInstallerPage { $this->parent->getInfoBox( wfMessage( $msg, $this->getVar( 'wgServer' ) . - $this->getVar( 'wgScriptPath' ) . '/index' . - $this->getVar( 'wgScriptExtension' ) + $this->getVar( 'wgScriptPath' ) . '/index' . + $this->getVar( 'wgScriptExtension' ) )->plain(), 'tick-32.png' ) ); $this->parent->restoreLinkPopups(); $this->endForm( $regenerate ? 'regenerate' : false, false ); } - } class WebInstaller_DBSettings extends WebInstallerPage { @@ -633,7 +654,6 @@ class WebInstaller_DBSettings extends WebInstallerPage { $this->addHTML( $form ); $this->endForm(); } - } class WebInstaller_Name extends WebInstallerPage { @@ -728,6 +748,7 @@ class WebInstaller_Name extends WebInstallerPage { $this->setVar( 'wgMetaNamespace', $metaNS ); $this->endForm(); + return 'output'; } @@ -841,7 +862,6 @@ class WebInstaller_Name extends WebInstallerPage { return $retVal; } - } class WebInstaller_Options extends WebInstallerPage { @@ -938,7 +958,7 @@ class WebInstaller_Options extends WebInstallerPage { } $extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) . - $this->getFieldSetEnd(); + $this->getFieldSetEnd(); $this->addHTML( $extHtml ); } @@ -1053,6 +1073,7 @@ class WebInstaller_Options extends WebInstallerPage { 'lang' => $this->getVar( '_UserLang' ), 'stylesheet' => $styleUrl, ) ); + return $iframeUrl; } @@ -1082,6 +1103,7 @@ class WebInstaller_Options extends WebInstallerPage { // If you change this height, also change it in config.css $expandJs = str_replace( '$1', '54em', $js ); $reduceJs = str_replace( '$1', '70px', $js ); + return '

' . Html::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) . '  ' . @@ -1108,6 +1130,7 @@ class WebInstaller_Options extends WebInstallerPage { array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) ); if ( count( $newValues ) != 3 ) { $this->parent->showError( 'config-cc-error' ); + return; } $this->setVar( '_CCDone', true ); @@ -1122,8 +1145,8 @@ class WebInstaller_Options extends WebInstallerPage { 'wgUseInstantCommons' ) ); if ( !in_array( $this->getVar( '_RightsProfile' ), - array_keys( $this->parent->rightsProfiles ) ) ) - { + array_keys( $this->parent->rightsProfiles ) ) + ) { reset( $this->parent->rightsProfiles ); $this->setVar( '_RightsProfile', key( $this->parent->rightsProfiles ) ); } @@ -1132,6 +1155,7 @@ class WebInstaller_Options extends WebInstallerPage { if ( $code == 'cc-choose' ) { if ( !$this->getVar( '_CCDone' ) ) { $this->parent->showError( 'config-cc-not-chosen' ); + return false; } } elseif ( in_array( $code, array_keys( $this->parent->licenses ) ) ) { @@ -1166,28 +1190,33 @@ class WebInstaller_Options extends WebInstallerPage { $memcServers = explode( "\n", $this->getVar( '_MemCachedServers' ) ); if ( !$memcServers ) { $this->parent->showError( 'config-memcache-needservers' ); + return false; } foreach ( $memcServers as $server ) { $memcParts = explode( ":", $server, 2 ); if ( !isset( $memcParts[0] ) - || ( !IP::isValid( $memcParts[0] ) - && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) ) ) { + || ( !IP::isValid( $memcParts[0] ) + && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) ) + ) { $this->parent->showError( 'config-memcache-badip', $memcParts[0] ); + return false; } elseif ( !isset( $memcParts[1] ) ) { $this->parent->showError( 'config-memcache-noport', $memcParts[0] ); + return false; } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) { $this->parent->showError( 'config-memcache-badport', 1, 65535 ); + return false; } } } + return true; } - } class WebInstaller_Install extends WebInstallerPage { @@ -1219,6 +1248,7 @@ class WebInstaller_Install extends WebInstallerPage { $this->addHTML( $this->parent->getInfoBox( wfMessage( 'config-install-begin' )->plain() ) ); $this->endForm(); } + return true; } @@ -1249,7 +1279,6 @@ class WebInstaller_Install extends WebInstallerPage { $this->parent->showStatusBox( $status ); } } - } class WebInstaller_Complete extends WebInstallerPage { @@ -1259,10 +1288,11 @@ class WebInstaller_Complete extends WebInstallerPage { // to download the file $lsUrl = $this->getVar( 'wgServer' ) . $this->parent->getURL( array( 'localsettings' => 1 ) ); if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && - strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) { + strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false + ) { // JS appears to be the only method that works consistently with IE7+ $this->addHtml( "\n\n" ); + Xml::encodeJsVar( $lsUrl ) . "; } );\n" ); } else { $this->parent->request->response()->header( "Refresh: 0;url=$lsUrl" ); } @@ -1274,8 +1304,8 @@ class WebInstaller_Complete extends WebInstallerPage { wfMessage( 'config-install-done', $lsUrl, $this->getVar( 'wgServer' ) . - $this->getVar( 'wgScriptPath' ) . '/index' . - $this->getVar( 'wgScriptExtension' ), + $this->getVar( 'wgScriptPath' ) . '/index' . + $this->getVar( 'wgScriptExtension' ), '' )->plain(), 'tick-32.png' ) @@ -1297,6 +1327,7 @@ class WebInstaller_Restart extends WebInstallerPage { if ( $really ) { $this->parent->reset(); } + return 'continue'; } @@ -1305,7 +1336,6 @@ class WebInstaller_Restart extends WebInstallerPage { $this->addHTML( $s ); $this->endForm( 'restart' ); } - } abstract class WebInstaller_Document extends WebInstallerPage { @@ -1322,12 +1352,12 @@ abstract class WebInstaller_Document extends WebInstallerPage { public function getFileContents() { $file = __DIR__ . '/../../' . $this->getFileName(); - if ( ! file_exists( $file ) ) { + if ( !file_exists( $file ) ) { return wfMessage( 'config-nofile', $file )->plain(); } + return file_get_contents( $file ); } - } class WebInstaller_Readme extends WebInstaller_Document { -- 2.20.1