Index: trunk/phase3/maintenance/install.php |
— | — | @@ -49,10 +49,14 @@ |
50 | 50 | $this->addOption( 'dbuser', 'The user to use for normal operations (wikiuser)', false, true ); |
51 | 51 | $this->addOption( 'dbpass', 'The pasword for the DB user for normal operations', false, true ); |
52 | 52 | $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 ); |
53 | 54 | /* $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */ |
54 | 55 | /* $this->addOption( 'dbtsearch2schema', 'The schema for the tsearch2 DB in pg (public)', false, true ); */ |
55 | 56 | /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */ |
56 | 57 | $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 | + |
57 | 61 | } |
58 | 62 | |
59 | 63 | public function execute() { |
Index: trunk/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -18,6 +18,8 @@ |
19 | 19 | 'config-localsettings-upgrade' => "A <code>LocalSettings.php</code> file has been detected. |
20 | 20 | To upgrade this installation, please enter the value of <code>\$wgUpgradeKey</code> in the box below. |
21 | 21 | 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.', |
22 | 24 | 'config-localsettings-key' => 'Upgrade key:', |
23 | 25 | 'config-localsettings-badkey' => 'The key you provided is incorrect.', |
24 | 26 | 'config-upgrade-key-missing' => 'An existing installation of MediaWiki has been detected. |
Index: trunk/phase3/includes/installer/CliInstaller.php |
— | — | @@ -32,6 +32,10 @@ |
33 | 33 | 'dbts2schema' => 'wgDBts2schema', |
34 | 34 | 'dbpath' => 'wgSQLiteDataDir', |
35 | 35 | 'scriptpath' => 'wgScriptPath', |
| 36 | + 'wikiroot' => 'wgScriptPath', |
| 37 | + 'upgrade' => 'cliUpgrade', /* As long as it isn't $confItems |
| 38 | + * in LocalSettingsGenerator, we |
| 39 | + * should be fine. */ |
36 | 40 | ); |
37 | 41 | |
38 | 42 | /** |
— | — | @@ -81,6 +85,15 @@ |
82 | 86 | * Main entry point. |
83 | 87 | */ |
84 | 88 | 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 | + |
85 | 98 | $this->performInstallation( |
86 | 99 | array( $this, 'startStage' ), |
87 | 100 | array( $this, 'endStage' ) |
— | — | @@ -103,32 +116,37 @@ |
104 | 117 | } |
105 | 118 | |
106 | 119 | 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 ); |
120 | 121 | $this->showMessage( wfMsg( 'config-install-step-done' ) . "\n" ); |
121 | 122 | } |
122 | 123 | |
123 | 124 | public function showMessage( $msg /*, ... */ ) { |
124 | 125 | $params = func_get_args(); |
125 | 126 | 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 ); |
127 | 132 | $text = preg_replace( '/<a href="(.*?)".*?>(.*?)<\/a>/', '$2 <$1>', $text ); |
128 | 133 | echo html_entity_decode( strip_tags( $text ), ENT_QUOTES ) . "\n"; |
129 | 134 | flush(); |
130 | 135 | } |
131 | 136 | |
132 | 137 | 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 | + } |
134 | 152 | } |
135 | 153 | } |