r78593 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78592‎ | r78593 | r78594 >
Date:04:55, 19 December 2010
Author:mah
Status:ok (Comments)
Tags:
Comment:
* Add --wikiroot option to CLI installer so the user can give something besides /wiki
* Add --upgrade option to CLI installer so we can throw an error when LocalSettings.php is present and provide an upgrade route to the user.
* Fixup CLI's showStatusMessage so allow CLI to throw an error and quit
Modified paths:
  • /trunk/phase3/includes/installer/CliInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/maintenance/install.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/install.php
@@ -49,10 +49,14 @@
5050 $this->addOption( 'dbuser', 'The user to use for normal operations (wikiuser)', false, true );
5151 $this->addOption( 'dbpass', 'The pasword for the DB user for normal operations', false, true );
5252 $this->addOption( 'confpath', "Path to write LocalSettings.php to, default $IP", false, true );
 53+ $this->addOption( 'wikiroot', "The URL to use for the wiki root (/wiki)", false, true );
5354 /* $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */
5455 /* $this->addOption( 'dbtsearch2schema', 'The schema for the tsearch2 DB in pg (public)', false, true ); */
5556 /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */
5657 $this->addOption( 'env-checks', "Run environment checks only, don't change anything" );
 58+ $this->addOption( 'upgrade',
 59+ 'Allow the upgrade to continue despite an existing LocalSettings.php', false, true );
 60+
5761 }
5862
5963 public function execute() {
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -18,6 +18,8 @@
1919 'config-localsettings-upgrade' => "A <code>LocalSettings.php</code> file has been detected.
2020 To upgrade this installation, please enter the value of <code>\$wgUpgradeKey</code> in the box below.
2121 You will find it in LocalSettings.php.",
 22+ 'config-localsettings-cli-upgrade' => 'A LocalSettings.php file has been detected.
 23+To upgrade this installation, please give the --upgrade=yes option.',
2224 'config-localsettings-key' => 'Upgrade key:',
2325 'config-localsettings-badkey' => 'The key you provided is incorrect.',
2426 'config-upgrade-key-missing' => 'An existing installation of MediaWiki has been detected.
Index: trunk/phase3/includes/installer/CliInstaller.php
@@ -32,6 +32,10 @@
3333 'dbts2schema' => 'wgDBts2schema',
3434 'dbpath' => 'wgSQLiteDataDir',
3535 'scriptpath' => 'wgScriptPath',
 36+ 'wikiroot' => 'wgScriptPath',
 37+ 'upgrade' => 'cliUpgrade', /* As long as it isn't $confItems
 38+ * in LocalSettingsGenerator, we
 39+ * should be fine. */
3640 );
3741
3842 /**
@@ -81,6 +85,15 @@
8286 * Main entry point.
8387 */
8488 public function execute() {
 89+ global $cliUpgrade;
 90+
 91+ $vars = $this->getExistingLocalSettings();
 92+ if( $vars && ( !isset( $cliUpgrade ) || $cliUpgrade !== "yes" ) ) {
 93+ $this->showStatusMessage(
 94+ Status::newFatal( "config-localsettings-cli-upgrade" )
 95+ );
 96+ }
 97+
8598 $this->performInstallation(
8699 array( $this, 'startStage' ),
87100 array( $this, 'endStage' )
@@ -103,32 +116,37 @@
104117 }
105118
106119 public function endStage( $step, $status ) {
107 - $warnings = $status->getWarningsArray();
108 -
109 - if ( !$status->isOk() ) {
110 - $this->showStatusMessage( $status );
111 - echo "\n";
112 - exit;
113 - } elseif ( count( $warnings ) !== 0 ) {
114 - foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
115 - $this->showMessage( $w . wfMsg( 'ellipsis' ) .
116 - wfMsg( 'word-separator' ) );
117 - }
118 - }
119 -
 120+ $this->showStatusMessage( $status );
120121 $this->showMessage( wfMsg( 'config-install-step-done' ) . "\n" );
121122 }
122123
123124 public function showMessage( $msg /*, ... */ ) {
124125 $params = func_get_args();
125126 array_shift( $params );
126 - $text = wfMsgExt( $msg, array( 'parseinline' ), $params );
 127+
 128+ /* parseinline has the nasty side-effect of putting encoded
 129+ * angle brackets, around the message, so the substr removes
 130+ * them. */
 131+ $text = substr( wfMsgExt( $msg, array( 'parseinline' ), $params ), 4, -4 );
127132 $text = preg_replace( '/<a href="(.*?)".*?>(.*?)<\/a>/', '$2 &lt;$1&gt;', $text );
128133 echo html_entity_decode( strip_tags( $text ), ENT_QUOTES ) . "\n";
129134 flush();
130135 }
131136
132137 public function showStatusMessage( Status $status ) {
133 - $this->showMessage( $status->getWikiText() );
 138+ $warnings = array_merge( $status->getWarningsArray(),
 139+ $status->getErrorsArray() );
 140+
 141+ if ( count( $warnings ) !== 0 ) {
 142+ foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
 143+ $this->showMessage( $w . wfMsg( 'ellipsis' ) .
 144+ wfMsg( 'word-separator' ) );
 145+ }
 146+ }
 147+
 148+ if ( !$status->isOk() ) {
 149+ echo "\n";
 150+ exit;
 151+ }
134152 }
135153 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r84328Fixed message borkage from r78593maxsem15:27, 19 March 2011
r84756Partial revert r78593 (adding --upgrade option to install.php). Rather than s...demon19:06, 25 March 2011

Comments

#Comment by Krinkle (talk | contribs)   14:04, 19 December 2010

The -wikiroot option was reverted in r78595.

#Comment by 😂 (talk | contribs)   03:37, 22 December 2010

You shouldn't need to be introducing a new global for this. If it's absolutely necessary, you should prefix it with $wg.

#Comment by MarkAHershberger (talk | contribs)   05:41, 22 December 2010

Since this global is local to only the installation script and is never put into the LocalSettings.php, I ignored all convention.

That said, it shouldn't be needed and I'll work at removing it.

#Comment by 😂 (talk | contribs)   20:32, 19 January 2011

Actually on looking at this more, I'm not sure why this is really needed. We already have upgrade.php, so why not just bail entirely if you detect LocalSettings?

#Comment by MaxSem (talk | contribs)   15:04, 19 March 2011

Ewwww, typical php install.php --env-checks output after this revision:

5.3.0 is instal
arning: Could not find eAccelerator, APC, XCache or WinCache.
Object caching is not enab
Invalid drive specification.
d GD graphics library built-in.
Image thumbnailing will be enabled if you enable uplo
g the intl PECL extension for Unicode normalizat
arning: The installed version of the Unicode normalization wrapper uses an older version of the ICU project's library.
You should upgrade if you are at all concerned about using Unic
environment has been checked.
You can install MediaW

How did you encounter these angle brackets?

#Comment by MarkAHershberger (talk | contribs)   15:17, 19 March 2011

Like "&ltWarning..."

But these may have been a sign of another bug that was repaired otherwise. What happens if you remove that line?

#Comment by MaxSem (talk | contribs)   15:28, 19 March 2011

Everything worked. I switched the removal to regex in r84328.

#Comment by 😂 (talk | contribs)   19:07, 25 March 2011

wikiroot and upgrade options were reverted, angle brackets fixed up as well. Marking OK.

Status & tagging log