r101886 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101885‎ | r101886 | r101887 >
Date:21:48, 3 November 2011
Author:awjrichards
Status:deferred
Tags:
Comment:
Modified paths:
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)

Diff [purge]

Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -240,16 +240,24 @@
241241 * @return boolean true if match, else false.
242242 */
243243 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();
245252
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;
250261 }
251 -
252 - $this->refreshGatewayValueFromSource( 'token' );
253 - return $checkResult;
254262 }
255263
256264 /**
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
@@ -105,7 +105,7 @@
106106
107107 //if we have saved any donation data to the session, pull them in as well.
108108 $this->integrateDataFromSession();
109 -
 109+
110110 $this->doCacheStuff();
111111
112112 $this->normalizeAndSanitize();
@@ -118,8 +118,7 @@
119119 * are populated, and merge that with the data set we already have.
120120 */
121121 function integrateDataFromSession(){
122 - self::ensureSession();
123 - if ( array_key_exists( 'Donor', $_SESSION ) ) {
 122+ if ( self::sessionExists() && array_key_exists( 'Donor', $_SESSION ) ) {
124123 //if the thing coming in from the session isn't already something,
125124 //replace it.
126125 //if it is: assume that the session data was meant to be replaced
@@ -405,6 +404,16 @@
406405 }
407406 }
408407
 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+ */
409418 function doCacheStuff() {
410419 //TODO: Wow, name.
411420 // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax
@@ -415,7 +424,7 @@
416425 // if we have squid caching enabled, set the maxage
417426 global $wgUseSquid, $wgOut;
418427 $maxAge = $this->getGatewayGlobal( 'SMaxAge' );
419 -
 428+
420429 if ( $wgUseSquid && ( $maxAge !== false ) ) {
421430 self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Setting s-max-age: ' . $maxAge, LOG_DEBUG );
422431 $wgOut->setSquidMaxage( $maxAge );
@@ -519,12 +528,22 @@
520529 */
521530 public static function ensureSession() {
522531 // if the session is already started, do nothing
523 - if ( session_id() )
 532+ if ( self::sessionExists() )
524533 return;
525534
526535 // otherwise, fire it up using global mw function wfSetupSession
527536 wfSetupSession();
528537 }
 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+ }
529548
530549 public function token_checkTokens() {
531550 global $wgRequest;
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface
___________________________________________________________________
Modified: svn:mergeinfo
532551 Merged /trunk/extensions/DonationInterface:r101878

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101878Fix: The squid log caching and the sessions were fighting eachother. Now, the...khorn20:54, 3 November 2011

Status & tagging log