Index: trunk/phase3/includes/User.php |
— | — | @@ -293,7 +293,7 @@ |
294 | 294 | $fname = 'User::loadDefaults' . $n; |
295 | 295 | wfProfileIn( $fname ); |
296 | 296 | |
297 | | - global $wgContLang, $wgDBname; |
| 297 | + global $wgContLang, $wgCookiePrefix; |
298 | 298 | global $wgNamespacesToBeSearchedDefault; |
299 | 299 | |
300 | 300 | $this->mId = 0; |
— | — | @@ -315,8 +315,8 @@ |
316 | 316 | $this->setToken(); # Random |
317 | 317 | $this->mHash = false; |
318 | 318 | |
319 | | - if ( isset( $_COOKIE[$wgDBname.'LoggedOut'] ) ) { |
320 | | - $this->mTouched = wfTimestamp( TS_MW, $_COOKIE[$wgDBname.'LoggedOut'] ); |
| 319 | + if ( isset( $_COOKIE[$wgCookiePrefix.'LoggedOut'] ) ) { |
| 320 | + $this->mTouched = wfTimestamp( TS_MW, $_COOKIE[$wgCookiePrefix.'LoggedOut'] ); |
321 | 321 | } |
322 | 322 | else { |
323 | 323 | $this->mTouched = '0'; # Allow any pages to be cached |
— | — | @@ -617,7 +617,7 @@ |
618 | 618 | * @static |
619 | 619 | */ |
620 | 620 | function loadFromSession() { |
621 | | - global $wgMemc, $wgDBname; |
| 621 | + global $wgMemc, $wgDBname, $wgCookiePrefix; |
622 | 622 | |
623 | 623 | if ( isset( $_SESSION['wsUserID'] ) ) { |
624 | 624 | if ( 0 != $_SESSION['wsUserID'] ) { |
— | — | @@ -625,16 +625,16 @@ |
626 | 626 | } else { |
627 | 627 | return new User(); |
628 | 628 | } |
629 | | - } else if ( isset( $_COOKIE["{$wgDBname}UserID"] ) ) { |
630 | | - $sId = intval( $_COOKIE["{$wgDBname}UserID"] ); |
| 629 | + } else if ( isset( $_COOKIE["{$wgCookiePrefix}UserID"] ) ) { |
| 630 | + $sId = intval( $_COOKIE["{$wgCookiePrefix}UserID"] ); |
631 | 631 | $_SESSION['wsUserID'] = $sId; |
632 | 632 | } else { |
633 | 633 | return new User(); |
634 | 634 | } |
635 | 635 | if ( isset( $_SESSION['wsUserName'] ) ) { |
636 | 636 | $sName = $_SESSION['wsUserName']; |
637 | | - } else if ( isset( $_COOKIE["{$wgDBname}UserName"] ) ) { |
638 | | - $sName = $_COOKIE["{$wgDBname}UserName"]; |
| 637 | + } else if ( isset( $_COOKIE["{$wgCookiePrefix}UserName"] ) ) { |
| 638 | + $sName = $_COOKIE["{$wgCookiePrefix}UserName"]; |
639 | 639 | $_SESSION['wsUserName'] = $sName; |
640 | 640 | } else { |
641 | 641 | return new User(); |
— | — | @@ -657,8 +657,8 @@ |
658 | 658 | |
659 | 659 | if ( isset( $_SESSION['wsToken'] ) ) { |
660 | 660 | $passwordCorrect = $_SESSION['wsToken'] == $user->mToken; |
661 | | - } else if ( isset( $_COOKIE["{$wgDBname}Token"] ) ) { |
662 | | - $passwordCorrect = $user->mToken == $_COOKIE["{$wgDBname}Token"]; |
| 661 | + } else if ( isset( $_COOKIE["{$wgCookiePrefix}Token"] ) ) { |
| 662 | + $passwordCorrect = $user->mToken == $_COOKIE["{$wgCookiePrefix}Token"]; |
663 | 663 | } else { |
664 | 664 | return new User(); # Can't log in from session |
665 | 665 | } |
Index: trunk/phase3/includes/SpecialUserlogin.php |
— | — | @@ -383,7 +383,8 @@ |
384 | 384 | * @access private |
385 | 385 | */ |
386 | 386 | function mailPasswordInternal( $u ) { |
387 | | - global $wgDBname, $wgCookiePath, $wgCookieDomain, $wgCookieSecure; |
| 387 | + global $wgPasswordSender, $wgIP; |
| 388 | + global $wgCookiePath, $wgCookieDomain, $wgCookiePrefix, $wgCookieSecure; |
388 | 389 | |
389 | 390 | if ( '' == $u->getEmail() ) { |
390 | 391 | return wfMsg( 'noemail', $u->getName() ); |
— | — | @@ -392,7 +393,7 @@ |
393 | 394 | $np = $u->randomPassword(); |
394 | 395 | $u->setNewpassword( $np ); |
395 | 396 | |
396 | | - setcookie( "{$wgDBname}Token", '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure ); |
| 397 | + setcookie( "{$wgCookiePrefix}Token", '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure ); |
397 | 398 | |
398 | 399 | $u->saveSettings(); |
399 | 400 | |
— | — | @@ -444,14 +445,15 @@ |
445 | 446 | */ |
446 | 447 | function mainLoginForm( $msg, $msgtype = 'error' ) { |
447 | 448 | global $wgUser, $wgOut, $wgLang; |
448 | | - global $wgDBname, $wgAllowRealName, $wgEnableEmail; |
| 449 | + global $wgAllowRealName, $wgEnableEmail; |
| 450 | + global $wgCookiePrefix; |
449 | 451 | global $wgAuth; |
450 | 452 | |
451 | 453 | if ( '' == $this->mName ) { |
452 | 454 | if ( $wgUser->isLoggedIn() ) { |
453 | 455 | $this->mName = $wgUser->getName(); |
454 | 456 | } else { |
455 | | - $this->mName = @$_COOKIE[$wgDBname.'UserName']; |
| 457 | + $this->mName = @$_COOKIE[$wgCookiePrefix.'UserName']; |
456 | 458 | } |
457 | 459 | } |
458 | 460 | |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -115,18 +115,21 @@ |
116 | 116 | wfProfileOut( $fname.'-memcached' ); |
117 | 117 | wfProfileIn( $fname.'-SetupSession' ); |
118 | 118 | |
| 119 | +if ( $wgDBprefix ) { |
| 120 | + $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix; |
| 121 | +} elseif ( $wgSharedDB ) { |
| 122 | + $wgCookiePrefix = $wgSharedDB; |
| 123 | +} else { |
| 124 | + $wgCookiePrefix = $wgDBname; |
| 125 | +} |
| 126 | + |
119 | 127 | # If session.auto_start is there, we can't touch session name |
120 | 128 | # |
121 | | - |
122 | 129 | if (!ini_get('session.auto_start')) { |
123 | | - if ( $wgDBprefix ) { |
124 | | - session_name( $wgDBname . '_' . $wgDBprefix . '_session' ); |
125 | | - } else { |
126 | | - session_name( $wgDBname . '_session' ); |
127 | | - } |
| 130 | + session_name( $wgCookiePrefix . '_session' ); |
128 | 131 | } |
129 | 132 | |
130 | | -if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgDBname.'Token'] ) ) ) { |
| 133 | +if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) { |
131 | 134 | wfIncrStats( 'request_with_session' ); |
132 | 135 | User::SetupSession(); |
133 | 136 | $wgSessionStarted = true; |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -608,6 +608,7 @@ |
609 | 609 | * (partial bug 3456) Disable auto redirect to Main Page after account creation |
610 | 610 | * (bug 4824) Separate out IE7 CSS compat hacks, fix for RTL pages |
611 | 611 | * Added support for wikidiff2 and similar external diff engines. |
| 612 | +* Allow cookies to be shared between multiple wikis with a shared user database |
612 | 613 | |
613 | 614 | |
614 | 615 | === Caveats === |