r85012 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85011‎ | r85012 | r85013 >
Date:14:46, 30 March 2011
Author:demon
Status:ok
Tags:
Comment:
MFT installer changes: r84755, r84756, r84875, r84881, r84882, r84970, r84976
Modified paths:
  • /branches/REL1_17/phase3/includes/installer (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/CliInstaller.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/Installer.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/MysqlUpdater.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/WebInstaller.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/WebInstallerOutput.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/WebInstallerPage.php (modified) (history)
  • /branches/REL1_17/phase3/maintenance/install.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/maintenance/install.php
@@ -50,7 +50,6 @@
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 );
5353 /* $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */
54 - /* $this->addOption( 'dbtsearch2schema', 'The schema for the tsearch2 DB in pg (public)', false, true ); */
5554 /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */
5655 $this->addOption( 'env-checks', "Run environment checks only, don't change anything" );
5756 }
@@ -73,6 +72,13 @@
7473 return;
7574 }
7675 } else {
 76+ $status = $installer->doEnvironmentChecks();
 77+ if( $status->isGood() ) {
 78+ $installer->showMessage( 'config-env-good' );
 79+ } else {
 80+ $installer->showStatusMessage( $status );
 81+ return;
 82+ }
7783 $installer->execute();
7884 $installer->writeConfigurationFile( $this->getOption( 'confpath', $IP ) );
7985 }
Property changes on: branches/REL1_17/phase3/maintenance/install.php
___________________________________________________________________
Added: svn:mergeinfo
8086 Merged /branches/sqlite/maintenance/install.php:r58211-58321
8187 Merged /trunk/phase3/maintenance/install.php:r79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,81519,84756
8288 Merged /branches/new-installer/phase3/maintenance/install.php:r43664-66004
8389 Merged /branches/REL1_15/phase3/maintenance/install.php:r51646
Property changes on: branches/REL1_17/phase3/includes/installer/MysqlUpdater.php
___________________________________________________________________
Modified: svn:mergeinfo
8490 Merged /trunk/phase3/includes/installer/MysqlUpdater.php:r84875,84881-84882,84970,84976
Index: branches/REL1_17/phase3/includes/installer/WebInstaller.php
@@ -177,6 +177,7 @@
178178 if ( $this->request->getVal( 'SubmitCC' ) ) {
179179 $page = $this->getPageByName( 'Options' );
180180 $this->output->useShortHeader();
 181+ $this->output->allowFrames();
181182 $page->submitCC();
182183 return $this->finish();
183184 }
@@ -184,6 +185,7 @@
185186 if ( $this->request->getVal( 'ShowCC' ) ) {
186187 $page = $this->getPageByName( 'Options' );
187188 $this->output->useShortHeader();
 189+ $this->output->allowFrames();
188190 $this->output->addHTML( $page->getCCDoneBox() );
189191 return $this->finish();
190192 }
@@ -323,7 +325,13 @@
324326 public function getFingerprint() {
325327 // Get the base URL of the installation
326328 $url = $this->request->getFullRequestURL();
 329+ if ( preg_match( '!^(.*\?)!', $url, $m) ) {
 330+ // Trim query string
 331+ $url = $m[1];
 332+ }
327333 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
 334+ // This... seems to try to get the base path from
 335+ // the /mw-config/index.php. Kinda scary though?
328336 $url = $m[1];
329337 }
330338 return md5( serialize( array(
Index: branches/REL1_17/phase3/includes/installer/Installer.php
@@ -1196,7 +1196,7 @@
11971197 * but we're not opening that can of worms
11981198 * @see https://bugzilla.wikimedia.org/show_bug.cgi?id=26857
11991199 */
1200 - global $wgHooks, $wgAutoloadClasses;
 1200+ global $wgAutoloadClasses;
12011201 require( "$IP/includes/DefaultSettings.php" );
12021202
12031203 foreach( $exts as $e ) {
@@ -1208,8 +1208,7 @@
12091209
12101210 // Unset everyone else's hooks. Lord knows what someone might be doing
12111211 // in ParserFirstCallInit (see bug 27171)
1212 - unset( $wgHooks );
1213 - $wgHooks = array( 'LoadExtensionSchemaUpdates' => $hooksWeWant );
 1212+ $GLOBALS['wgHooks'] = array( 'LoadExtensionSchemaUpdates' => $hooksWeWant );
12141213
12151214 return Status::newGood();
12161215 }
@@ -1232,8 +1231,7 @@
12331232 array( 'name' => 'tables', 'callback' => array( $installer, 'createTables' ) ),
12341233 array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
12351234 array( 'name' => 'stats', 'callback' => array( $this, 'populateSiteStats' ) ),
1236 - array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ),
1237 - array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ),
 1235+ array( 'name' => 'keys', 'callback' => array( $this, 'generateKeys' ) ),
12381236 array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
12391237 array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
12401238 );
@@ -1313,59 +1311,55 @@
13141312 *
13151313 * @return Status
13161314 */
1317 - protected function generateSecretKey() {
1318 - return $this->generateSecret( 'wgSecretKey' );
 1315+ public function generateKeys() {
 1316+ $keys = array( 'wgSecretKey' => 64 );
 1317+ if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
 1318+ $keys['wgUpgradeKey'] = 16;
 1319+ }
 1320+ return $this->doGenerateKeys( $keys );
13191321 }
13201322
13211323 /**
1322 - * Generate a secret value for a variable using either
1323 - * /dev/urandom or mt_rand() Produce a warning in the later case.
 1324+ * Generate a secret value for variables using either
 1325+ * /dev/urandom or mt_rand(). Produce a warning in the later case.
13241326 *
 1327+ * @param $keys Array
13251328 * @return Status
13261329 */
1327 - protected function generateSecret( $secretName, $length = 64 ) {
1328 - if ( wfIsWindows() ) {
1329 - $file = null;
1330 - } else {
1331 - wfSuppressWarnings();
1332 - $file = fopen( "/dev/urandom", "r" );
1333 - wfRestoreWarnings();
1334 - }
1335 -
 1330+ protected function doGenerateKeys( $keys ) {
13361331 $status = Status::newGood();
13371332
1338 - if ( $file ) {
1339 - $secretKey = bin2hex( fread( $file, $length / 2 ) );
1340 - fclose( $file );
1341 - } else {
1342 - $secretKey = '';
 1333+ wfSuppressWarnings();
 1334+ $file = fopen( "/dev/urandom", "r" );
 1335+ wfRestoreWarnings();
13431336
1344 - for ( $i = 0; $i < $length / 8; $i++ ) {
1345 - $secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
 1337+ foreach ( $keys as $name => $length ) {
 1338+ if ( $file ) {
 1339+ $secretKey = bin2hex( fread( $file, $length / 2 ) );
 1340+ } else {
 1341+ $secretKey = '';
 1342+
 1343+ for ( $i = 0; $i < $length / 8; $i++ ) {
 1344+ $secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
 1345+ }
13461346 }
13471347
1348 - $status->warning( 'config-insecure-secret', '$' . $secretName );
 1348+ $this->setVar( $name, $secretKey );
13491349 }
13501350
1351 - $this->setVar( $secretName, $secretKey );
 1351+ if ( $file ) {
 1352+ fclose( $file );
 1353+ } else {
 1354+ $names = array_keys ( $keys );
 1355+ $names = preg_replace( '/^(.*)$/', '\$$1', $names );
 1356+ global $wgLang;
 1357+ $status->warning( 'config-insecure-keys', $wgLang->listToText( $names ), count( $names ) );
 1358+ }
13521359
13531360 return $status;
13541361 }
13551362
13561363 /**
1357 - * Generate a default $wgUpgradeKey. Will warn if we had to use
1358 - * mt_rand() instead of /dev/urandom
1359 - *
1360 - * @return Status
1361 - */
1362 - public function generateUpgradeKey() {
1363 - if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
1364 - return $this->generateSecret( 'wgUpgradeKey', 16 );
1365 - }
1366 - return Status::newGood();
1367 - }
1368 -
1369 - /**
13701364 * Create the first user account, grant it sysop and bureaucrat rights
13711365 *
13721366 * @return Status
Property changes on: branches/REL1_17/phase3/includes/installer/Installer.php
___________________________________________________________________
Added: svn:mergeinfo
13731367 Merged /branches/new-installer/phase3/includes/installer/Installer.php:r43664-66004
13741368 Merged /branches/wmf-deployment/includes/installer/Installer.php:r53381
13751369 Merged /branches/REL1_15/phase3/includes/installer/Installer.php:r51646
13761370 Merged /branches/sqlite/includes/installer/Installer.php:r58211-58321
13771371 Merged /trunk/phase3/includes/installer/Installer.php:r82845,82847-82848,84755,84875,84881-84882,84970,84976
Index: branches/REL1_17/phase3/includes/installer/Installer.i18n.php
@@ -19,7 +19,7 @@
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.",
2222 'config-localsettings-cli-upgrade' => 'A LocalSettings.php file has been detected.
23 -To upgrade this installation, please give the --upgrade=yes option.',
 23+To upgrade this installation, please run update.php instead',
2424 'config-localsettings-key' => 'Upgrade key:',
2525 'config-localsettings-badkey' => 'The key you provided is incorrect.',
2626 'config-upgrade-key-missing' => 'An existing installation of MediaWiki has been detected.
@@ -490,10 +490,8 @@
491491 'config-install-interwiki-exists' => "'''Warning''': The interwiki table seems to already have entries.
492492 Skipping default list.",
493493 'config-install-stats' => 'Initializing statistics',
494 - 'config-install-secretkey' => 'Generating secret key',
495 - 'config-insecure-secret' => "'''Warning:''' Unable to create a secure <code>$1</code>.
496 -Consider changing it manually.",
497 - 'config-install-upgradekey' => 'Generating default upgrade key',
 494+ 'config-install-keys' => 'Generating secret keys',
 495+ 'config-insecure-keys' => "'''Warning:''' {{PLURAL:$2|A secure key|Secure keys}} $1 generated during installation are not completely safe. Consider changing {{PLURAL:$2|it|them}} manually.",
498496 'config-install-sysop' => 'Creating administrator user account',
499497 'config-install-subscribe-fail' => 'Unable to subscribe to mediawiki-announce',
500498 'config-install-mainpage' => 'Creating main page with default content',
Property changes on: branches/REL1_17/phase3/includes/installer/Installer.i18n.php
___________________________________________________________________
Added: svn:mergeinfo
501499 Merged /branches/new-installer/phase3/includes/installer/Installer.i18n.php:r43664-66004
502500 Merged /branches/wmf-deployment/includes/installer/Installer.i18n.php:r53381
503501 Merged /branches/REL1_15/phase3/includes/installer/Installer.i18n.php:r51646
504502 Merged /branches/sqlite/includes/installer/Installer.i18n.php:r58211-58321
505503 Merged /trunk/phase3/includes/installer/Installer.i18n.php:r82845,82847-82848,84756,84875,84881-84882,84970,84976
Index: branches/REL1_17/phase3/includes/installer/WebInstallerOutput.php
@@ -40,6 +40,14 @@
4141 public $redirectTarget;
4242
4343 /**
 44+ * Does the current page need to allow being used as a frame?
 45+ * If not, X-Frame-Options will be output to forbid it.
 46+ *
 47+ * @var bool
 48+ */
 49+ public $allowFrames = false;
 50+
 51+ /**
4452 * Whether to use the limited header (used during CC license callbacks)
4553 * @var bool
4654 */
@@ -116,6 +124,10 @@
117125 $this->useShortHeader = $use;
118126 }
119127
 128+ public function allowFrames( $allow = true ) {
 129+ $this->allowFrames = $allow;
 130+ }
 131+
120132 public function flush() {
121133 if ( !$this->headerDone ) {
122134 $this->outputHeader();
@@ -163,7 +175,9 @@
164176 $dbTypes = $this->parent->getDBTypes();
165177
166178 $this->parent->request->response()->header( 'Content-Type: text/html; charset=utf-8' );
167 - $this->parent->request->response()->header( 'X-Frame-Options: DENY' );
 179+ if (!$this->allowFrames) {
 180+ $this->parent->request->response()->header( 'X-Frame-Options: DENY' );
 181+ }
168182 if ( $this->redirectTarget ) {
169183 $this->parent->request->response()->header( 'Location: '.$this->redirectTarget );
170184 return;
Index: branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
@@ -494,13 +494,14 @@
495495 * @return String
496496 */
497497 public function getWebUserBox( $noCreateMsg = false ) {
 498+ $wrapperStyle = $this->getVar( '_SameAccount' ) ? 'display: none' : '';
498499 $s = Html::openElement( 'fieldset' ) .
499500 Html::element( 'legend', array(), wfMsg( 'config-db-web-account' ) ) .
500501 $this->getCheckBox(
501502 '_SameAccount', 'config-db-web-account-same',
502503 array( 'class' => 'hideShowRadio', 'rel' => 'dbOtherAccount' )
503504 ) .
504 - Html::openElement( 'div', array( 'id' => 'dbOtherAccount', 'style' => 'display: none;' ) ) .
 505+ Html::openElement( 'div', array( 'id' => 'dbOtherAccount', 'style' => $wrapperStyle ) ) .
505506 $this->getTextBox( 'wgDBuser', 'config-db-username' ) .
506507 $this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) .
507508 $this->parent->getHelpBox( 'config-db-web-help' );
Property changes on: branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
___________________________________________________________________
Modified: svn:mergeinfo
508509 Merged /trunk/phase3/includes/installer/DatabaseInstaller.php:r84875,84881-84882,84970,84976
Index: branches/REL1_17/phase3/includes/installer/CliInstaller.php
@@ -31,9 +31,6 @@
3232 'dbschema' => 'wgDBmwschema',
3333 'dbpath' => 'wgSQLiteDataDir',
3434 'scriptpath' => 'wgScriptPath',
35 - 'upgrade' => 'cliUpgrade', /* As long as it isn't $confItems
36 - * in LocalSettingsGenerator, we
37 - * should be fine. */
3835 );
3936
4037 /**
@@ -91,10 +88,8 @@
9289 * Main entry point.
9390 */
9491 public function execute() {
95 - global $cliUpgrade;
96 -
9792 $vars = $this->getExistingLocalSettings();
98 - if( $vars && ( !isset( $cliUpgrade ) || $cliUpgrade !== "yes" ) ) {
 93+ if( $vars ) {
9994 $this->showStatusMessage(
10095 Status::newFatal( "config-localsettings-cli-upgrade" )
10196 );
Property changes on: branches/REL1_17/phase3/includes/installer/CliInstaller.php
___________________________________________________________________
Added: svn:mergeinfo
10297 Merged /branches/sqlite/includes/installer/CliInstaller.php:r58211-58321
10398 Merged /trunk/phase3/includes/installer/CliInstaller.php:r82845,82847-82848,84756,84875,84881-84882,84970,84976
10499 Merged /branches/new-installer/phase3/includes/installer/CliInstaller.php:r43664-66004
105100 Merged /branches/wmf-deployment/includes/installer/CliInstaller.php:r53381
106101 Merged /branches/REL1_15/phase3/includes/installer/CliInstaller.php:r51646
Index: branches/REL1_17/phase3/includes/installer/WebInstallerPage.php
@@ -475,6 +475,11 @@
476476 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
477477 $this->parent->output->flush();
478478 if ( $result ) {
 479+ // If they're going to possibly regenerate LocalSettings, we
 480+ // need to create the upgrade/secret keys. Bug 26481
 481+ if( !$this->getVar( '_ExistingDBSettings' ) ) {
 482+ $this->parent->generateKeys();
 483+ }
479484 $this->setVar( '_UpgradeDone', true );
480485 $this->showDoneMessage();
481486 return 'output';
@@ -745,6 +750,7 @@
746751 }
747752 }
748753
 754+ $emailwrapperStyle = $this->getVar( 'wgEnableEmail' ) ? '' : 'display: none';
749755 $this->startForm();
750756 $this->addHTML(
751757 # User Rights
@@ -775,7 +781,7 @@
776782 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
777783 ) ) .
778784 $this->parent->getHelpBox( 'config-enable-email-help' ) .
779 - "<div id=\"emailwrapper\">" .
 785+ "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
780786 $this->parent->getTextBox( array(
781787 'var' => 'wgPasswordSender',
782788 'label' => 'config-email-sender'
@@ -830,6 +836,7 @@
831837 )
832838 );
833839
 840+ $uploadwrapperStyle = $this->getVar( 'wgEnableUploads' ) ? '' : 'display: none';
834841 $this->addHTML(
835842 # Uploading
836843 $this->getFieldSetStart( 'config-upload-settings' ) .
@@ -839,7 +846,7 @@
840847 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
841848 'help' => $this->parent->getHelpBox( 'config-upload-help' )
842849 ) ) .
843 - '<div id="uploadwrapper" style="display: none;">' .
 850+ '<div id="uploadwrapper" style="' . $uploadwrapperStyle . '">' .
844851 $this->parent->getTextBox( array(
845852 'var' => 'wgDeletedDirectory',
846853 'label' => 'config-upload-deleted',
@@ -927,9 +934,10 @@
928935 } else {
929936 $iframeAttribs['src'] = $this->getCCPartnerUrl();
930937 }
 938+ $wrapperStyle = ($this->getVar('_LicenseCode') == 'cc-choose') ? '' : 'display: none';
931939
932940 return
933 - "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
 941+ "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
934942 Html::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
935943 "</div>\n";
936944 }
Property changes on: branches/REL1_17/phase3/includes/installer/WebInstallerPage.php
___________________________________________________________________
Modified: svn:mergeinfo
937945 Merged /trunk/phase3/includes/installer/WebInstallerPage.php:r84875,84881-84882,84970,84976
Property changes on: branches/REL1_17/phase3/includes/installer
___________________________________________________________________
Added: svn:mergeinfo
938946 Merged /branches/REL1_15/phase3/includes/installer:r51646
939947 Merged /branches/sqlite/includes/installer:r58211-58321
940948 Merged /trunk/phase3/includes/installer:r82845,82847-82848,84875,84881-84882,84970,84976
941949 Merged /branches/new-installer/phase3/includes/installer:r43664-66004
942950 Merged /branches/wmf-deployment/includes/installer:r53381

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84755(bug 27171) Incorrect error message during extension installation. lol @ PHP'...maxsem18:24, 25 March 2011
r84756Partial revert r78593 (adding --upgrade option to install.php). Rather than s...demon19:06, 25 March 2011
r84875* (bug 26937) [Installer] Fix for Javascript-opened sections being incorrectl...brion19:22, 27 March 2011
r84881* (bug 27170) [Installer] Install now completes when choosing a CC license wi...brion20:13, 27 March 2011
r84882Further cleanup on installer: fix visibility of CC selector results when retu...brion20:19, 27 March 2011
r84970(bug 26481) $wgUpgradeKey/$wgSecretKey values sometimes not filled - only hap...demon17:06, 29 March 2011
r84976Tweaks for key generation:...maxsem19:00, 29 March 2011

Status & tagging log