Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -240,16 +240,24 @@ |
241 | 241 | * @return boolean true if match, else false. |
242 | 242 | */ |
243 | 243 | public function checkTokens() { |
244 | | - $checkResult = $this->dataObj->token_checkTokens(); |
| 244 | + if ( !$this->posted ) { |
| 245 | + //we don't care, because we can't possibly have a good one at this |
| 246 | + //point. |
| 247 | + //Additional: If we try for this before we're posted, the squid log |
| 248 | + //caching won't work. |
| 249 | + return true; |
| 250 | + } else { |
| 251 | + $checkResult = $this->dataObj->token_checkTokens(); |
245 | 252 | |
246 | | - if ( $checkResult ) { |
247 | | - $this->debugarray[] = 'Token Match'; |
248 | | - } else { |
249 | | - $this->debugarray[] = 'Token MISMATCH'; |
| 253 | + if ( $checkResult ) { |
| 254 | + $this->debugarray[] = 'Token Match'; |
| 255 | + } else { |
| 256 | + $this->debugarray[] = 'Token MISMATCH'; |
| 257 | + } |
| 258 | + |
| 259 | + $this->refreshGatewayValueFromSource( 'token' ); |
| 260 | + return $checkResult; |
250 | 261 | } |
251 | | - |
252 | | - $this->refreshGatewayValueFromSource( 'token' ); |
253 | | - return $checkResult; |
254 | 262 | } |
255 | 263 | |
256 | 264 | /** |
Index: branches/fundraising/deployment/payments_1.17/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 |
— | — | @@ -405,6 +404,16 @@ |
406 | 405 | } |
407 | 406 | } |
408 | 407 | |
| 408 | + /** |
| 409 | + * This function sets the token to the string 'cache' if we're caching, and |
| 410 | + * then sets the s-maxage header to whatever you specify for the SMaxAge. |
| 411 | + * NOTES: The bit where we setSquidMaxage will not work at all, under two |
| 412 | + * conditions: |
| 413 | + * The user has a session ID. |
| 414 | + * The mediawiki_session cookie is set in the user's browser. |
| 415 | + * @global bool $wgUseSquid |
| 416 | + * @global type $wgOut |
| 417 | + */ |
409 | 418 | function doCacheStuff() { |
410 | 419 | //TODO: Wow, name. |
411 | 420 | // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax |
— | — | @@ -415,7 +424,7 @@ |
416 | 425 | // if we have squid caching enabled, set the maxage |
417 | 426 | global $wgUseSquid, $wgOut; |
418 | 427 | $maxAge = $this->getGatewayGlobal( 'SMaxAge' ); |
419 | | - |
| 428 | + |
420 | 429 | if ( $wgUseSquid && ( $maxAge !== false ) ) { |
421 | 430 | self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Setting s-max-age: ' . $maxAge, LOG_DEBUG ); |
422 | 431 | $wgOut->setSquidMaxage( $maxAge ); |
— | — | @@ -519,12 +528,22 @@ |
520 | 529 | */ |
521 | 530 | public static function ensureSession() { |
522 | 531 | // if the session is already started, do nothing |
523 | | - if ( session_id() ) |
| 532 | + if ( self::sessionExists() ) |
524 | 533 | return; |
525 | 534 | |
526 | 535 | // otherwise, fire it up using global mw function wfSetupSession |
527 | 536 | wfSetupSession(); |
528 | 537 | } |
| 538 | + |
| 539 | + /** |
| 540 | + * Checks to see if the session exists without actually creating one. |
| 541 | + * @return bool true if we have a session, otherwise false. |
| 542 | + */ |
| 543 | + public static function sessionExists() { |
| 544 | + if ( session_id() ) |
| 545 | + return true; |
| 546 | + return false; |
| 547 | + } |
529 | 548 | |
530 | 549 | public function token_checkTokens() { |
531 | 550 | global $wgRequest; |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface |
___________________________________________________________________ |
Modified: svn:mergeinfo |
532 | 551 | Merged /trunk/extensions/DonationInterface:r101878 |