Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -64,11 +64,8 @@ |
65 | 65 | // Display form for the first time |
66 | 66 | $this->displayForm( $this->errors ); |
67 | 67 | } |
68 | | - } else { |
69 | | - if ( !$this->adapter->isCaching() ) { |
70 | | - // if we're not caching, there's a token mismatch |
71 | | - $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' ); |
72 | | - } |
| 68 | + } else {//token mismatch |
| 69 | + $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' ); |
73 | 70 | $this->displayForm( $this->errors ); |
74 | 71 | } |
75 | 72 | } |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php |
— | — | @@ -188,11 +188,8 @@ |
189 | 189 | |
190 | 190 | $this->displayForm( $this->errors ); |
191 | 191 | } |
192 | | - } else { |
193 | | - if ( !$this->adapter->isCaching() ) { |
194 | | - // if we're not caching, there's a token mismatch |
195 | | - $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' ); |
196 | | - } |
| 192 | + } else { //token mismatch |
| 193 | + $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' ); |
197 | 194 | $this->displayForm( $this->errors ); |
198 | 195 | } |
199 | 196 | } |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php |
— | — | @@ -59,9 +59,6 @@ |
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | | - |
64 | | - |
65 | | - |
66 | 63 | $wgOut->addExtensionStyle( |
67 | 64 | $wgExtensionAssetsPath . '/DonationInterface/gateway_forms/css/gateway.css?284' . |
68 | 65 | $this->adapter->getGlobal( 'CSSVersion' ) ); |
— | — | @@ -104,12 +101,7 @@ |
105 | 102 | } //TODO: There really should be an else here. |
106 | 103 | } |
107 | 104 | } |
108 | | - } else { |
109 | | - if ( !$this->adapter->isCaching() ) { |
110 | | - // if we're not caching, there's a token mismatch |
111 | | - $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' ); |
112 | | - } |
113 | | - } |
| 105 | + } |
114 | 106 | } |
115 | 107 | |
116 | 108 | /** |
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -318,24 +318,20 @@ |
319 | 319 | * @return boolean true if match, else false. |
320 | 320 | */ |
321 | 321 | public function checkTokens() { |
322 | | - if ( !$this->posted ) { |
323 | | - //we don't care, because we can't possibly have a good one at this |
324 | | - //point. |
325 | | - //Additional: If we try for this before we're posted, the squid log |
326 | | - //caching won't work. |
327 | | - return true; |
328 | | - } else { |
329 | | - $checkResult = $this->dataObj->token_checkTokens(); |
| 322 | + $checkResult = $this->dataObj->token_checkTokens(); |
330 | 323 | |
331 | | - if ( $checkResult ) { |
332 | | - $this->debugarray[] = 'Token Match'; |
| 324 | + if ( $checkResult ) { |
| 325 | + if ($this->dataObj->isCaching()){ |
| 326 | + $this->debugarray[] = 'Token Not Checked (Caching Enabled)'; |
333 | 327 | } else { |
334 | | - $this->debugarray[] = 'Token MISMATCH'; |
| 328 | + $this->debugarray[] = 'Token Match'; |
335 | 329 | } |
336 | | - |
337 | | - $this->refreshGatewayValueFromSource( 'token' ); |
338 | | - return $checkResult; |
| 330 | + } else { |
| 331 | + $this->debugarray[] = 'Token MISMATCH'; |
339 | 332 | } |
| 333 | + |
| 334 | + $this->refreshGatewayValueFromSource( 'token' ); |
| 335 | + return $checkResult; |
340 | 336 | } |
341 | 337 | |
342 | 338 | /** |
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -357,11 +357,16 @@ |
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | | - |
| 361 | + /** |
| 362 | + * Tells us if we think we're in caching mode or not. |
| 363 | + * @staticvar string $cache Keeps track of the mode so we don't have to |
| 364 | + * calculate it from the data fields more than once. |
| 365 | + * @return boolean true if we are going to be caching, false if we aren't. |
| 366 | + */ |
362 | 367 | function isCaching(){ |
363 | | - //I think it's safe to static this here. I don't want to calc this every |
364 | | - //time some outside object asks if we're caching. |
| 368 | + |
365 | 369 | static $cache = null; |
| 370 | + |
366 | 371 | if ( is_null( $cache ) ){ |
367 | 372 | if ( $this->getVal( '_cache_' ) === 'true' ){ //::head. hit. keyboard.:: |
368 | 373 | if ( $this->isSomething( 'utm_source_id' ) && !is_null( 'utm_source_id' ) ){ |
— | — | @@ -372,6 +377,13 @@ |
373 | 378 | $cache = false; |
374 | 379 | } |
375 | 380 | } |
| 381 | + |
| 382 | + //this business could change at any second, and it will prevent us from |
| 383 | + //caching, so we're going to keep asking if it's set. |
| 384 | + if (self::sessionExists()){ |
| 385 | + $cache = false; |
| 386 | + } |
| 387 | + |
376 | 388 | return $cache; |
377 | 389 | } |
378 | 390 | |
— | — | @@ -654,6 +666,13 @@ |
655 | 667 | static $match = null; |
656 | 668 | |
657 | 669 | if ( $match === null ) { |
| 670 | + if ( $this->isCaching() ){ |
| 671 | + //This makes sense. |
| 672 | + //If all three conditions for caching are currently true, the |
| 673 | + //last thing we want to do is screw it up by setting a session |
| 674 | + //token before the page loads. |
| 675 | + return true; |
| 676 | + } |
658 | 677 | |
659 | 678 | // establish the edit token to prevent csrf |
660 | 679 | $token = $this->token_getSaltedSessionToken(); |