r69518 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69517‎ | r69518 | r69519 >
Date:18:52, 18 July 2010
Author:mah
Status:ok
Tags:
Comment:
* 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
Modified paths:
  • /trunk/phase3/includes/installer/CliInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/maintenance/sqlite/archives/initial-indexes.sql (modified) (history)
  • /trunk/phase3/maintenance/sqlite/archives/patch-tc-timestamp.sql (modified) (history)
  • /trunk/phase3/maintenance/sqlite/archives/searchindex-fts3.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/sqlite/archives/patch-tc-timestamp.sql
@@ -1,3 +1,3 @@
22 UPDATE /*_*/transcache SET tc_time = strftime('%Y%m%d%H%M%S', datetime(tc_time, 'unixepoch'));
33
4 -INSERT INTO /*_*/updatelog VALUES ('convert transcache field');
 4+INSERT INTO /*_*/updatelog (ul_key) VALUES ('convert transcache field');
Index: trunk/phase3/maintenance/sqlite/archives/initial-indexes.sql
@@ -413,4 +413,4 @@
414414 CREATE INDEX /*i*/qcc_title ON /*_*/querycachetwo (qcc_type,qcc_namespace,qcc_title);
415415 CREATE INDEX /*i*/qcc_titletwo ON /*_*/querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
416416
417 -INSERT INTO /*_*/updatelog VALUES ('initial_indexes');
 417+INSERT INTO /*_*/updatelog (ul_key) VALUES ('initial_indexes');
Index: trunk/phase3/maintenance/sqlite/archives/searchindex-fts3.sql
@@ -15,4 +15,4 @@
1616 si_text
1717 );
1818
19 -INSERT INTO /*_*/updatelog VALUES ('fts3');
\ No newline at end of file
 19+INSERT INTO /*_*/updatelog (ul_key) VALUES ('fts3');
\ No newline at end of file
Index: trunk/phase3/includes/installer/Installer.php
@@ -8,14 +8,14 @@
99 var $settings, $output;
1010
1111 /**
12 - * MediaWiki configuration globals that will eventually be passed through
13 - * to LocalSettings.php. The names only are given here, the defaults
 12+ * MediaWiki configuration globals that will eventually be passed through
 13+ * to LocalSettings.php. The names only are given here, the defaults
1414 * typically come from DefaultSettings.php.
1515 */
1616 protected $defaultVarNames = array(
1717 'wgSitename',
1818 'wgPasswordSender',
19 - 'wgLanguageCode',
 19+ 'wgLanguageCode',
2020 'wgRightsIcon',
2121 'wgRightsText',
2222 'wgRightsUrl',
@@ -41,8 +41,8 @@
4242 );
4343
4444 /**
45 - * Variables that are stored alongside globals, and are used for any
46 - * configuration of the installation process aside from the MediaWiki
 45+ * Variables that are stored alongside globals, and are used for any
 46+ * configuration of the installation process aside from the MediaWiki
4747 * configuration. Map of names to defaults.
4848 */
4949 protected $internalDefaults = array(
@@ -77,7 +77,7 @@
7878 * Known database types. These correspond to the class names <type>Installer,
7979 * and are also MediaWiki database types valid for $wgDBtype.
8080 *
81 - * To add a new type, create a <type>Installer class and a Database<type>
 81+ * To add a new type, create a <type>Installer class and a Database<type>
8282 * class, and add a config-type-<type> message to MessagesEn.php.
8383 */
8484 private $dbTypes = array(
@@ -98,8 +98,8 @@
9999 private $dbInstallers = array();
100100
101101 /**
102 - * A list of environment check methods called by doEnvironmentChecks().
103 - * These may output warnings using showMessage(), and/or abort the
 102+ * A list of environment check methods called by doEnvironmentChecks().
 103+ * These may output warnings using showMessage(), and/or abort the
104104 * installation process by returning false.
105105 */
106106 protected $envChecks = array(
@@ -154,7 +154,7 @@
155155 '*' => array( 'edit' => false )
156156 ),
157157 'fishbowl' => array(
158 - '*' => array(
 158+ '*' => array(
159159 'createaccount' => false,
160160 'edit' => false,
161161 ),
@@ -199,7 +199,7 @@
200200 ),
201201 'cc-choose' => array(
202202 // details will be filled in by the selector
203 - 'url' => '',
 203+ 'url' => '',
204204 'icon' => '',
205205 'text' => '',
206206 ),
@@ -257,7 +257,7 @@
258258 /**
259259 * UI interface for displaying a short message
260260 * The parameters are like parameters to wfMsg().
261 - * The messages will be in wikitext format, which will be converted to an
 261+ * The messages will be in wikitext format, which will be converted to an
262262 * output format such as HTML or text before being sent to the user.
263263 */
264264 abstract function showMessage( $msg /*, ... */ );
@@ -289,14 +289,14 @@
290290 }
291291
292292 /**
293 - * Do initial checks of the PHP environment. Set variables according to
 293+ * Do initial checks of the PHP environment. Set variables according to
294294 * the observed environment.
295295 *
296296 * It's possible that this may be called under the CLI SAPI, not the SAPI
297297 * that the wiki will primarily run under. In that case, the subclass should
298298 * initialise variables such as wgScriptPath, before calling this function.
299299 *
300 - * Under the web subclass, it can already be assumed that PHP 5+ is in use
 300+ * Under the web subclass, it can already be assumed that PHP 5+ is in use
301301 * and that sessions are working.
302302 */
303303 function doEnvironmentChecks() {
@@ -359,7 +359,7 @@
360360 }
361361
362362 /**
363 - * Set a variable which stores a password, except if the new value is a
 363+ * Set a variable which stores a password, except if the new value is a
364364 * fake password in which case leave it as it is.
365365 */
366366 function setPassword( $name, $value ) {
@@ -367,7 +367,7 @@
368368 $this->setVar( $name, $value );
369369 }
370370 }
371 -
 371+
372372 /** Check if we're installing the latest version */
373373 function envLatestVersion() {
374374 global $wgVersion;
@@ -391,7 +391,7 @@
392392 }
393393 if( version_compare( $wgVersion, $currentVersion, '<' ) ) {
394394 $this->showMessage( 'config-env-latest-old' );
395 - $this->showHelpBox( 'config-env-latest-help', $wgVersion, $currentVersion );
 395+ $this->showHelpBox( 'config-env-latest-help', $wgVersion, $currentVersion );
396396 } elseif( version_compare( $wgVersion, $currentVersion, '>' ) ) {
397397 $this->showMessage( 'config-env-latest-new' );
398398 }
@@ -557,17 +557,17 @@
558558 }
559559
560560 /**
561 - * Search a path for any of the given executable names. Returns the
562 - * executable name if found. Also checks the version string returned
 561+ * Search a path for any of the given executable names. Returns the
 562+ * executable name if found. Also checks the version string returned
563563 * by each executable
564564 *
565565 * @param $path String: path to search
566566 * @param $names Array of executable names
567567 * @param $versionInfo Boolean false or array with two members:
568 - * 0 => Command to run for version check, with $1 for the path
569 - * 1 => String to compare the output with
 568+ * 0 => Command to run for version check, with $1 for the path
 569+ * 1 => String to compare the output with
570570 *
571 - * If $versionInfo is not false, only executables with a version
 571+ * If $versionInfo is not false, only executables with a version
572572 * matching $versionInfo[1] will be returned.
573573 */
574574 function locateExecutable( $path, $names, $versionInfo = false ) {
@@ -582,7 +582,7 @@
583583
584584 $file = str_replace( '$1', $command, $versionInfo[0] );
585585 # Should maybe be wfShellExec( $file), but runs into a ulimit, see
586 - # http://www.mediawiki.org/w/index.php?title=New-installer_issues&diff=prev&oldid=335456
 586+ # http://www.mediawiki.org/w/index.php?title=New-installer_issues&diff=prev&oldid=335456
587587 if ( strstr( `$file`, $versionInfo[1]) !== false )
588588 return $command;
589589 }
@@ -732,7 +732,7 @@
733733 # Give up
734734 return true;
735735 }
736 -
 736+
737737 function envCheckUploadsDirectory() {
738738 global $IP, $wgServer;
739739 $dir = $IP . '/images/';
@@ -780,12 +780,12 @@
781781 * Convert wikitext $text to HTML.
782782 *
783783 * This is potentially error prone since many parser features require a complete
784 - * installed MW database. The solution is to just not use those features when you
 784+ * installed MW database. The solution is to just not use those features when you
785785 * write your messages. This appears to work well enough. Basic formatting and
786786 * external links work just fine.
787787 *
788 - * But in case a translator decides to throw in a #ifexist or internal link or
789 - * whatever, this function is guarded to catch attempted DB access and to present
 788+ * But in case a translator decides to throw in a #ifexist or internal link or
 789+ * whatever, this function is guarded to catch attempted DB access and to present
790790 * some fallback text.
791791 *
792792 * @param $text String
@@ -819,8 +819,8 @@
820820 */
821821 function docLink( $linkText, $attribs, $parser ) {
822822 $url = $this->getDocUrl( $attribs['href'] );
823 - return '<a href="' . htmlspecialchars( $url ) . '">' .
824 - htmlspecialchars( $linkText ) .
 823+ return '<a href="' . htmlspecialchars( $url ) . '">' .
 824+ htmlspecialchars( $linkText ) .
825825 '</a>';
826826 }
827827
@@ -987,7 +987,7 @@
988988 wfSuppressWarnings();
989989 $ls = file_exists( "$IP/LocalSettings.php" );
990990 wfRestoreWarnings();
991 -
 991+
992992 if( $ls ) {
993993 if( $this->getDBInstaller()->needsUpgrade() ) {
994994 $status->warning( 'config-localsettings-upgrade' );
@@ -1044,7 +1044,7 @@
10451045 }
10461046
10471047 /**
1048 - * Add an installation step following the given step.
 1048+ * Add an installation step following the given step.
10491049 * @param $findStep String the step to find. Use NULL to put the step at the beginning.
10501050 * @param $callback array
10511051 */
Index: trunk/phase3/includes/installer/CliInstaller.php
@@ -47,9 +47,6 @@
4848 $this->setVar( 'wgSitename', $siteName );
4949 if ( $admin ) {
5050 $this->setVar( '_AdminName', $admin );
51 - } else {
52 - $this->setVar( '_AdminName',
53 - wfMsgForContent( 'config-admin-default-username' ) );
5451 }
5552
5653 if ( !isset( $option['installdbuser'] ) ) {
@@ -67,26 +64,31 @@
6865 /**
6966 * Main entry point.
7067 */
71 - function execute( ) {
72 - foreach( $this->getInstallSteps() as $stepObj ) {
73 - $step = is_array( $stepObj ) ? $stepObj['name'] : $stepObj;
74 - $this->showMessage( wfMsg( "config-install-$step") .
75 - wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) );
76 - $func = 'install' . ucfirst( $step );
77 - $status = $this->{$func}();
78 - $warnings = $status->getWarningsArray();
79 - if ( !$status->isOk() ) {
80 - $this->showStatusMessage( $status );
81 - echo "\n";
82 - exit;
83 - } elseif ( count($warnings) !== 0 ) {
84 - foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
85 - $this->showMessage( $w . wfMsg( 'ellipsis') .
86 - wfMsg( 'word-separator' ) );
87 - }
 68+ public function execute( ) {
 69+ $this->performInstallation(
 70+ array( $this, 'startStage'),
 71+ array( $this, 'endStage' )
 72+ );
 73+ }
 74+
 75+ public function startStage( $step ) {
 76+ $this->showMessage( wfMsg( "config-install-$step") .
 77+ wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) );
 78+ }
 79+
 80+ public function endStage( $step, $status ) {
 81+ $warnings = $status->getWarningsArray();
 82+ if ( !$status->isOk() ) {
 83+ $this->showStatusMessage( $status );
 84+ echo "\n";
 85+ exit;
 86+ } elseif ( count($warnings) !== 0 ) {
 87+ foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
 88+ $this->showMessage( $w . wfMsg( 'ellipsis') .
 89+ wfMsg( 'word-separator' ) );
8890 }
89 - $this->showMessage( wfMsg( 'config-install-step-done' ) ."\n");
9091 }
 92+ $this->showMessage( wfMsg( 'config-install-step-done' ) ."\n");
9193 }
9294
9395 function showMessage( $msg /*, ... */ ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r64217WikiSysop is back, and now (s)he's localisable!maxsem17:51, 26 March 2010
r69332Revert r64217 (WikiSysop is back, and now (s)he's localisable) per comments o...demon17:28, 14 July 2010

Status & tagging log