From 572bfe1228e5c3298f5bc1c81c2fef6a15db8470 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Sun, 18 Jul 2010 18:52:05 +0000 Subject: [PATCH] * re r69332, r64217: complete removal of WikiSysop for CLI installer * Incorporate new Installer::performInstallation() function * Update SQLite schema tables to insert data to updatelog correctly --- includes/installer/CliInstaller.php | 44 +++++++------- includes/installer/Installer.php | 60 +++++++++---------- .../sqlite/archives/initial-indexes.sql | 2 +- .../sqlite/archives/patch-tc-timestamp.sql | 2 +- .../sqlite/archives/searchindex-fts3.sql | 2 +- 5 files changed, 56 insertions(+), 54 deletions(-) diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index 51ffeb60b5..3f0c958084 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -47,9 +47,6 @@ class CliInstaller extends Installer { $this->setVar( 'wgSitename', $siteName ); if ( $admin ) { $this->setVar( '_AdminName', $admin ); - } else { - $this->setVar( '_AdminName', - wfMsgForContent( 'config-admin-default-username' ) ); } if ( !isset( $option['installdbuser'] ) ) { @@ -67,26 +64,31 @@ class CliInstaller extends Installer { /** * Main entry point. */ - function execute( ) { - foreach( $this->getInstallSteps() as $stepObj ) { - $step = is_array( $stepObj ) ? $stepObj['name'] : $stepObj; - $this->showMessage( wfMsg( "config-install-$step") . - wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) ); - $func = 'install' . ucfirst( $step ); - $status = $this->{$func}(); - $warnings = $status->getWarningsArray(); - if ( !$status->isOk() ) { - $this->showStatusMessage( $status ); - echo "\n"; - exit; - } elseif ( count($warnings) !== 0 ) { - foreach ( $status->getWikiTextArray( $warnings ) as $w ) { - $this->showMessage( $w . wfMsg( 'ellipsis') . - wfMsg( 'word-separator' ) ); - } + public function execute( ) { + $this->performInstallation( + array( $this, 'startStage'), + array( $this, 'endStage' ) + ); + } + + public function startStage( $step ) { + $this->showMessage( wfMsg( "config-install-$step") . + wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) ); + } + + public function endStage( $step, $status ) { + $warnings = $status->getWarningsArray(); + if ( !$status->isOk() ) { + $this->showStatusMessage( $status ); + echo "\n"; + exit; + } elseif ( count($warnings) !== 0 ) { + foreach ( $status->getWikiTextArray( $warnings ) as $w ) { + $this->showMessage( $w . wfMsg( 'ellipsis') . + wfMsg( 'word-separator' ) ); } - $this->showMessage( wfMsg( 'config-install-step-done' ) ."\n"); } + $this->showMessage( wfMsg( 'config-install-step-done' ) ."\n"); } function showMessage( $msg /*, ... */ ) { diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 8ef9e7a6e2..37c4923aae 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -8,14 +8,14 @@ abstract class Installer { var $settings, $output; /** - * MediaWiki configuration globals that will eventually be passed through - * to LocalSettings.php. The names only are given here, the defaults + * MediaWiki configuration globals that will eventually be passed through + * to LocalSettings.php. The names only are given here, the defaults * typically come from DefaultSettings.php. */ protected $defaultVarNames = array( 'wgSitename', 'wgPasswordSender', - 'wgLanguageCode', + 'wgLanguageCode', 'wgRightsIcon', 'wgRightsText', 'wgRightsUrl', @@ -41,8 +41,8 @@ abstract class Installer { ); /** - * Variables that are stored alongside globals, and are used for any - * configuration of the installation process aside from the MediaWiki + * Variables that are stored alongside globals, and are used for any + * configuration of the installation process aside from the MediaWiki * configuration. Map of names to defaults. */ protected $internalDefaults = array( @@ -77,7 +77,7 @@ abstract class Installer { * Known database types. These correspond to the class names Installer, * and are also MediaWiki database types valid for $wgDBtype. * - * To add a new type, create a Installer class and a Database + * To add a new type, create a Installer class and a Database * class, and add a config-type- message to MessagesEn.php. */ private $dbTypes = array( @@ -98,8 +98,8 @@ abstract class Installer { private $dbInstallers = array(); /** - * A list of environment check methods called by doEnvironmentChecks(). - * These may output warnings using showMessage(), and/or abort the + * A list of environment check methods called by doEnvironmentChecks(). + * These may output warnings using showMessage(), and/or abort the * installation process by returning false. */ protected $envChecks = array( @@ -154,7 +154,7 @@ abstract class Installer { '*' => array( 'edit' => false ) ), 'fishbowl' => array( - '*' => array( + '*' => array( 'createaccount' => false, 'edit' => false, ), @@ -199,7 +199,7 @@ abstract class Installer { ), 'cc-choose' => array( // details will be filled in by the selector - 'url' => '', + 'url' => '', 'icon' => '', 'text' => '', ), @@ -257,7 +257,7 @@ abstract class Installer { /** * UI interface for displaying a short message * The parameters are like parameters to wfMsg(). - * The messages will be in wikitext format, which will be converted to an + * 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. */ abstract function showMessage( $msg /*, ... */ ); @@ -289,14 +289,14 @@ abstract class Installer { } /** - * Do initial checks of the PHP environment. Set variables according to + * Do initial checks of the PHP environment. Set variables according to * the observed environment. * * It's possible that this may be called under the CLI SAPI, not the SAPI * that the wiki will primarily run under. In that case, the subclass should * initialise variables such as wgScriptPath, before calling this function. * - * Under the web subclass, it can already be assumed that PHP 5+ is in use + * Under the web subclass, it can already be assumed that PHP 5+ is in use * and that sessions are working. */ function doEnvironmentChecks() { @@ -359,7 +359,7 @@ abstract class Installer { } /** - * Set a variable which stores a password, except if the new value is a + * Set a variable which stores a password, except if the new value is a * fake password in which case leave it as it is. */ function setPassword( $name, $value ) { @@ -367,7 +367,7 @@ abstract class Installer { $this->setVar( $name, $value ); } } - + /** Check if we're installing the latest version */ function envLatestVersion() { global $wgVersion; @@ -391,7 +391,7 @@ abstract class Installer { } if( version_compare( $wgVersion, $currentVersion, '<' ) ) { $this->showMessage( 'config-env-latest-old' ); - $this->showHelpBox( 'config-env-latest-help', $wgVersion, $currentVersion ); + $this->showHelpBox( 'config-env-latest-help', $wgVersion, $currentVersion ); } elseif( version_compare( $wgVersion, $currentVersion, '>' ) ) { $this->showMessage( 'config-env-latest-new' ); } @@ -557,17 +557,17 @@ abstract class Installer { } /** - * Search a path for any of the given executable names. Returns the - * executable name if found. Also checks the version string returned + * Search a path for any of the given executable names. Returns the + * executable name if found. Also checks the version string returned * by each executable * * @param $path String: path to search * @param $names Array of executable names * @param $versionInfo Boolean false or array with two members: - * 0 => Command to run for version check, with $1 for the path - * 1 => String to compare the output with + * 0 => Command to run for version check, with $1 for the path + * 1 => String to compare the output with * - * If $versionInfo is not false, only executables with a version + * If $versionInfo is not false, only executables with a version * matching $versionInfo[1] will be returned. */ function locateExecutable( $path, $names, $versionInfo = false ) { @@ -582,7 +582,7 @@ abstract class Installer { $file = str_replace( '$1', $command, $versionInfo[0] ); # Should maybe be wfShellExec( $file), but runs into a ulimit, see - # http://www.mediawiki.org/w/index.php?title=New-installer_issues&diff=prev&oldid=335456 + # http://www.mediawiki.org/w/index.php?title=New-installer_issues&diff=prev&oldid=335456 if ( strstr( `$file`, $versionInfo[1]) !== false ) return $command; } @@ -732,7 +732,7 @@ abstract class Installer { # Give up return true; } - + function envCheckUploadsDirectory() { global $IP, $wgServer; $dir = $IP . '/images/'; @@ -780,12 +780,12 @@ abstract class Installer { * Convert wikitext $text to HTML. * * This is potentially error prone since many parser features require a complete - * installed MW database. The solution is to just not use those features when you + * installed MW database. The solution is to just not use those features when you * 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 - * whatever, this function is guarded to catch attempted DB access and to present + * But in case a translator decides to throw in a #ifexist or internal link or + * whatever, this function is guarded to catch attempted DB access and to present * some fallback text. * * @param $text String @@ -819,8 +819,8 @@ abstract class Installer { */ function docLink( $linkText, $attribs, $parser ) { $url = $this->getDocUrl( $attribs['href'] ); - return '' . - htmlspecialchars( $linkText ) . + return '' . + htmlspecialchars( $linkText ) . ''; } @@ -987,7 +987,7 @@ abstract class Installer { wfSuppressWarnings(); $ls = file_exists( "$IP/LocalSettings.php" ); wfRestoreWarnings(); - + if( $ls ) { if( $this->getDBInstaller()->needsUpgrade() ) { $status->warning( 'config-localsettings-upgrade' ); @@ -1044,7 +1044,7 @@ abstract class Installer { } /** - * Add an installation step following the given step. + * Add an installation step following the given step. * @param $findStep String the step to find. Use NULL to put the step at the beginning. * @param $callback array */ diff --git a/maintenance/sqlite/archives/initial-indexes.sql b/maintenance/sqlite/archives/initial-indexes.sql index f08511631c..2573ca13d9 100644 --- a/maintenance/sqlite/archives/initial-indexes.sql +++ b/maintenance/sqlite/archives/initial-indexes.sql @@ -413,4 +413,4 @@ CREATE INDEX /*i*/qcc_type ON /*_*/querycachetwo (qcc_type,qcc_value); CREATE INDEX /*i*/qcc_title ON /*_*/querycachetwo (qcc_type,qcc_namespace,qcc_title); CREATE INDEX /*i*/qcc_titletwo ON /*_*/querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo); -INSERT INTO /*_*/updatelog VALUES ('initial_indexes'); +INSERT INTO /*_*/updatelog (ul_key) VALUES ('initial_indexes'); diff --git a/maintenance/sqlite/archives/patch-tc-timestamp.sql b/maintenance/sqlite/archives/patch-tc-timestamp.sql index 551a5f1c22..5c09bf3574 100644 --- a/maintenance/sqlite/archives/patch-tc-timestamp.sql +++ b/maintenance/sqlite/archives/patch-tc-timestamp.sql @@ -1,3 +1,3 @@ UPDATE /*_*/transcache SET tc_time = strftime('%Y%m%d%H%M%S', datetime(tc_time, 'unixepoch')); -INSERT INTO /*_*/updatelog VALUES ('convert transcache field'); +INSERT INTO /*_*/updatelog (ul_key) VALUES ('convert transcache field'); diff --git a/maintenance/sqlite/archives/searchindex-fts3.sql b/maintenance/sqlite/archives/searchindex-fts3.sql index c3a86894b7..28554c02fc 100644 --- a/maintenance/sqlite/archives/searchindex-fts3.sql +++ b/maintenance/sqlite/archives/searchindex-fts3.sql @@ -15,4 +15,4 @@ CREATE VIRTUAL TABLE /*_*/searchindex USING FTS3( si_text ); -INSERT INTO /*_*/updatelog VALUES ('fts3'); \ No newline at end of file +INSERT INTO /*_*/updatelog (ul_key) VALUES ('fts3'); \ No newline at end of file -- 2.20.1