Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -241,16 +241,24 @@ |
242 | 242 | * @return boolean true if match, else false. |
243 | 243 | */ |
244 | 244 | public function checkTokens() { |
245 | | - $checkResult = $this->dataObj->token_checkTokens(); |
| 245 | + if ( !$this->posted ) { |
| 246 | + //we don't care, because we can't possibly have a good one at this |
| 247 | + //point. |
| 248 | + //Additional: If we try for this before we're posted, the squid log |
| 249 | + //caching won't work. |
| 250 | + return true; |
| 251 | + } else { |
| 252 | + $checkResult = $this->dataObj->token_checkTokens(); |
246 | 253 | |
247 | | - if ( $checkResult ) { |
248 | | - $this->debugarray[] = 'Token Match'; |
249 | | - } else { |
250 | | - $this->debugarray[] = 'Token MISMATCH'; |
| 254 | + if ( $checkResult ) { |
| 255 | + $this->debugarray[] = 'Token Match'; |
| 256 | + } else { |
| 257 | + $this->debugarray[] = 'Token MISMATCH'; |
| 258 | + } |
| 259 | + |
| 260 | + $this->refreshGatewayValueFromSource( 'token' ); |
| 261 | + return $checkResult; |
251 | 262 | } |
252 | | - |
253 | | - $this->refreshGatewayValueFromSource( 'token' ); |
254 | | - return $checkResult; |
255 | 263 | } |
256 | 264 | |
257 | 265 | /** |
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | |
107 | 107 | //if we have saved any donation data to the session, pull them in as well. |
108 | 108 | $this->integrateDataFromSession(); |
109 | | - |
| 109 | + |
110 | 110 | $this->doCacheStuff(); |
111 | 111 | |
112 | 112 | $this->normalizeAndSanitize(); |
— | — | @@ -118,8 +118,7 @@ |
119 | 119 | * are populated, and merge that with the data set we already have. |
120 | 120 | */ |
121 | 121 | function integrateDataFromSession(){ |
122 | | - self::ensureSession(); |
123 | | - if ( array_key_exists( 'Donor', $_SESSION ) ) { |
| 122 | + if ( self::sessionExists() && array_key_exists( 'Donor', $_SESSION ) ) { |
124 | 123 | //if the thing coming in from the session isn't already something, |
125 | 124 | //replace it. |
126 | 125 | //if it is: assume that the session data was meant to be replaced |
— | — | @@ -431,6 +430,16 @@ |
432 | 431 | } |
433 | 432 | } |
434 | 433 | |
| 434 | + /** |
| 435 | + * This function sets the token to the string 'cache' if we're caching, and |
| 436 | + * then sets the s-maxage header to whatever you specify for the SMaxAge. |
| 437 | + * NOTES: The bit where we setSquidMaxage will not work at all, under two |
| 438 | + * conditions: |
| 439 | + * The user has a session ID. |
| 440 | + * The mediawiki_session cookie is set in the user's browser. |
| 441 | + * @global bool $wgUseSquid |
| 442 | + * @global type $wgOut |
| 443 | + */ |
435 | 444 | function doCacheStuff() { |
436 | 445 | //TODO: Wow, name. |
437 | 446 | // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax |
— | — | @@ -441,7 +450,7 @@ |
442 | 451 | // if we have squid caching enabled, set the maxage |
443 | 452 | global $wgUseSquid, $wgOut; |
444 | 453 | $maxAge = $this->getGatewayGlobal( 'SMaxAge' ); |
445 | | - |
| 454 | + |
446 | 455 | if ( $wgUseSquid && ( $maxAge !== false ) ) { |
447 | 456 | self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Setting s-max-age: ' . $maxAge, LOG_DEBUG ); |
448 | 457 | $wgOut->setSquidMaxage( $maxAge ); |
— | — | @@ -545,12 +554,22 @@ |
546 | 555 | */ |
547 | 556 | public static function ensureSession() { |
548 | 557 | // if the session is already started, do nothing |
549 | | - if ( session_id() ) |
| 558 | + if ( self::sessionExists() ) |
550 | 559 | return; |
551 | 560 | |
552 | 561 | // otherwise, fire it up using global mw function wfSetupSession |
553 | 562 | wfSetupSession(); |
554 | 563 | } |
| 564 | + |
| 565 | + /** |
| 566 | + * Checks to see if the session exists without actually creating one. |
| 567 | + * @return bool true if we have a session, otherwise false. |
| 568 | + */ |
| 569 | + public static function sessionExists() { |
| 570 | + if ( session_id() ) |
| 571 | + return true; |
| 572 | + return false; |
| 573 | + } |
555 | 574 | |
556 | 575 | public function token_checkTokens() { |
557 | 576 | global $wgRequest; |