r77873 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77872‎ | r77873 | r77874 >
Date:13:20, 6 December 2010
Author:tstarling
Status:ok
Tags:
Comment:
* Made it possible to run multiple installer instances in the same cookie domain without them overwriting or misinterpreting each others' sessions. This is mostly paranoia: one could imagine a situation where the installer from one version of MW becomes insecure when run on the session from another. Did this by making installerData an array indexed by a hash of path and $wgVersion. I could have used $wgCookiePrefix, but that would have broken NoLocalSettings.php, which has no access to AutoLoader and so can't access Installer methods.

* Moved most of the functionality of config/index.php from the file level to a function, so that we can have local variables.
Modified paths:
  • /trunk/phase3/config/index.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -332,6 +332,25 @@
333333 }
334334
335335 /**
 336+ * Get a hash of data identifying this MW installation.
 337+ *
 338+ * This is used by config/index.php to prevent multiple installations of MW
 339+ * on the same cookie domain from interfering with each other.
 340+ */
 341+ public function getFingerprint() {
 342+ // Get the base URL of the installation
 343+ $url = $this->request->getFullRequestURL();
 344+ if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
 345+ $url = $m[1];
 346+ }
 347+ return md5( serialize( array(
 348+ 'local path' => dirname( dirname( __FILE__ ) ),
 349+ 'url' => $url,
 350+ 'version' => $GLOBALS['wgVersion']
 351+ ) ) );
 352+ }
 353+
 354+ /**
336355 * Show an error message in a box. Parameters are like wfMsg().
337356 */
338357 public function showError( $msg /*...*/ ) {
@@ -929,4 +948,4 @@
930949 return $url;
931950 }
932951
933 -}
\ No newline at end of file
 952+}
Index: trunk/phase3/config/index.php
@@ -11,27 +11,38 @@
1212 chdir( ".." );
1313 require( './includes/WebStart.php' );
1414
15 -$installer = new WebInstaller( $wgRequest );
 15+wfInstallerMain();
1616
17 -if ( !$installer->startSession() ) {
18 - $installer->finish();
19 - exit;
20 -}
 17+function wfInstallerMain() {
 18+ global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
2119
22 -$session = isset( $_SESSION['installData'] ) ? $_SESSION['installData'] : array();
 20+ $installer = new WebInstaller( $wgRequest );
2321
24 -if ( isset( $session['settings']['_UserLang'] ) ) {
25 - $langCode = $session['settings']['_UserLang'];
26 -} elseif ( !is_null( $wgRequest->getVal( 'UserLang' ) ) ) {
27 - $langCode = $wgRequest->getVal( 'UserLang' );
28 -} else {
29 - $langCode = 'en';
30 -}
31 -$wgLang = Language::factory( $langCode );
 22+ if ( !$installer->startSession() ) {
 23+ $installer->finish();
 24+ exit;
 25+ }
3226
33 -$wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
 27+ $fingerprint = $installer->getFingerprint();
 28+ if ( isset( $_SESSION['installData'][$fingerprint] ) ) {
 29+ $session = $_SESSION['installData'][$fingerprint];
 30+ } else {
 31+ $session = array();
 32+ }
3433
35 -$session = $installer->execute( $session );
 34+ if ( isset( $session['settings']['_UserLang'] ) ) {
 35+ $langCode = $session['settings']['_UserLang'];
 36+ } elseif ( !is_null( $wgRequest->getVal( 'UserLang' ) ) ) {
 37+ $langCode = $wgRequest->getVal( 'UserLang' );
 38+ } else {
 39+ $langCode = 'en';
 40+ }
 41+ $wgLang = Language::factory( $langCode );
3642
37 -$_SESSION['installData'] = $session;
 43+ $wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
3844
 45+ $session = $installer->execute( $session );
 46+
 47+ $_SESSION['installData'][$fingerprint] = $session;
 48+
 49+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r88588$wgArticle is deprecated! Possible removal in 1.20 or 1.21!...demon17:59, 22 May 2011

Status & tagging log