r101786 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101785‎ | r101786 | r101787 >
Date:04:34, 3 November 2011
Author:khorn
Status:ok
Tags:
Comment:
Cleans up all the cache functions that were all supposed to accomplish the same thing (finding out if we're caching), and collapses them into one function.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/tests/DonationDataTestCase.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/tests/DonationDataTestCase.php
@@ -303,7 +303,6 @@
304304 /**
305305 * TODO: Make sure ALL these functions in DonationData are tested, either directly or through a calling function.
306306 * I know that's more regression-ish, but I stand by it. :p
307 - function isCache(){
308307 function setNormalizedOrderIDs(){
309308 function generateOrderId() {
310309 public function sanitizeInput( &$value, $key, $flags=ENT_COMPAT, $double_encode=false ) {
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -65,7 +65,7 @@
6666 $this->displayForm( $this->errors );
6767 }
6868 } else {
69 - if ( !$this->adapter->isCache() ) {
 69+ if ( !$this->adapter->isCaching() ) {
7070 // if we're not caching, there's a token mismatch
7171 $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' );
7272 }
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php
@@ -92,7 +92,7 @@
9393 }
9494 }
9595 } else {
96 - if ( !$this->adapter->isCache() ) {
 96+ if ( !$this->adapter->isCaching() ) {
9797 // if we're not caching, there's a token mismatch
9898 $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' );
9999 }
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
@@ -133,7 +133,7 @@
134134 $this->displayForm( $this->errors );
135135 }
136136 } else {
137 - if ( !$this->adapter->isCache() ) {
 137+ if ( !$this->adapter->isCaching() ) {
138138 // if we're not caching, there's a token mismatch
139139 $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' );
140140 }
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -294,8 +294,8 @@
295295 }
296296 }
297297
298 - function isCache() {
299 - return $this->dataObj->isCache();
 298+ function isCaching() {
 299+ return $this->dataObj->isCaching();
300300 }
301301
302302 /**
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php
@@ -143,10 +143,6 @@
144144 return $this->normalized;
145145 }
146146
147 - function isCache() {
148 - return $this->cache;
149 - }
150 -
151147 function populateData_Test( $testdata = false ) {
152148 // define arrays of cc's and cc #s for random selection
153149 $cards = array( 'american' );
@@ -273,19 +269,27 @@
274270 */
275271 function handleContributionTrackingID(){
276272 if ( !$this->isSomething( 'contribution_tracking_id' ) &&
277 - ( !$this->canCache() ) ){
 273+ ( !$this->isCaching() ) ){
278274 $this->saveContributionTracking();
279275 }
280276 }
281277
282278
283 - function canCache(){
284 - if ( $this->getVal( '_cache_' ) === 'true' ){ //::head. hit. keyboard.::
285 - if ( $this->isSomething( 'utm_source_id' ) && !is_null( 'utm_source_id' ) ){
286 - return true;
 279+ function isCaching(){
 280+ //I think it's safe to static this here. I don't want to calc this every
 281+ //time some outside object asks if we're caching.
 282+ static $cache = null;
 283+ if ( is_null( $cache ) ){
 284+ if ( $this->getVal( '_cache_' ) === 'true' ){ //::head. hit. keyboard.::
 285+ if ( $this->isSomething( 'utm_source_id' ) && !is_null( 'utm_source_id' ) ){
 286+ $cache = true;
 287+ }
287288 }
 289+ if ( is_null( $cache ) ){
 290+ $cache = false;
 291+ }
288292 }
289 - return false;
 293+ return $cache;
290294 }
291295
292296 /**
@@ -404,9 +408,8 @@
405409 function doCacheStuff() {
406410 //TODO: Wow, name.
407411 // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax
408 - if ( $this->isSomething( '_cache_' ) ) {
 412+ if ( $this->isCaching() ) {
409413 self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Cache requested', LOG_DEBUG );
410 - $this->cache = true; //TODO: If we don't need this, kill it in the face.
411414 $this->setVal( 'token', 'cache' );
412415
413416 // if we have squid caching enabled, set the maxage
@@ -417,8 +420,6 @@
418421 self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Setting s-max-age: ' . $maxAge, LOG_DEBUG );
419422 $wgOut->setSquidMaxage( $maxAge );
420423 }
421 - } else {
422 - $this->cache = false; //TODO: Kill this one in the face, too. (see above)
423424 }
424425 }
425426

Follow-up revisions

RevisionCommit summaryAuthorDate
r101847MFT r101778, r101781, r101786, r101787, r101788, r101789awjrichards18:44, 3 November 2011

Status & tagging log