Index: branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -14,6 +14,7 @@ |
15 | 15 | //TODO: Actually think about this bit. |
16 | 16 | // ...and keep in mind we can re-populate if it's a test or whatever. (But that may not be a good idea either) |
17 | 17 | $this->boss = $owning_class; |
| 18 | + $this->gatewayID = $this->getGatewayIdentifier(); |
18 | 19 | $this->populateData( $test, $data ); |
19 | 20 | } |
20 | 21 | |
— | — | @@ -275,21 +276,34 @@ |
276 | 277 | } |
277 | 278 | |
278 | 279 | function log( $message, $log_level=LOG_INFO ) { |
279 | | - if ( class_exists( $this->boss ) ) { |
280 | | - $c = $this->boss; |
| 280 | + $c = $this->getAdapterClass(); |
| 281 | + if ( $c && is_callable( array( $c, 'log' ) )){ |
281 | 282 | $c::log( $message, $log_level ); |
282 | 283 | } |
283 | 284 | } |
| 285 | + |
| 286 | + function getGatewayIdentifier() { |
| 287 | + $c = $this->getAdapterClass(); |
| 288 | + if ( $c && is_callable( array( $c, 'getIdentifier' ) ) ){ |
| 289 | + return $c::getIdentifier(); |
| 290 | + } else { |
| 291 | + return 'DonationData'; |
| 292 | + } |
| 293 | + } |
| 294 | + |
| 295 | + function getGatewayGlobal( $varname ) { |
| 296 | + $c = $this->getAdapterClass(); |
| 297 | + if ( $c && is_callable( array( $c, 'getGlobal' ) ) ){ |
| 298 | + return $c::getGlobal( $varname ); |
| 299 | + } else { |
| 300 | + return false; |
| 301 | + } |
| 302 | + } |
284 | 303 | |
285 | 304 | function setGateway() { |
286 | 305 | //TODO: Hum. If we have some other gateway in the form data, should we go crazy here? (Probably) |
287 | | - if ( class_exists( $this->boss ) ) { |
288 | | - $c = $this->boss; |
289 | | - if ( is_callable( array( $c, 'getIdentifier' ) ) ) { |
290 | | - $gateway = $c::getIdentifier(); |
291 | | - $this->setVal( 'gateway', $gateway ); |
292 | | - } |
293 | | - } |
| 306 | + $gateway = $this->gatewayID; |
| 307 | + $this->setVal( 'gateway', $gateway ); |
294 | 308 | } |
295 | 309 | |
296 | 310 | function doCacheStuff() { |
— | — | @@ -304,14 +318,11 @@ |
305 | 319 | |
306 | 320 | // if we have squid caching enabled, set the maxage |
307 | 321 | global $wgUseSquid, $wgOut; |
308 | | - if ( class_exists( $this->boss ) ) { |
309 | | - $g = $this->boss; //the 'g' is for "Gateway"! |
310 | | - $maxAge = $g::getGlobal( 'SMaxAge' ); |
| 322 | + $maxAge = $this->getGatewayGlobal( 'SMaxAge' ); |
311 | 323 | |
312 | | - if ( $wgUseSquid ) { |
313 | | - self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Setting s-max-age: ' . $maxAge, LOG_DEBUG ); |
314 | | - $wgOut->setSquidMaxage( $maxAge ); |
315 | | - } |
| 324 | + if ( $wgUseSquid && ( $maxAge !== false ) ) { |
| 325 | + self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Setting s-max-age: ' . $maxAge, LOG_DEBUG ); |
| 326 | + $wgOut->setSquidMaxage( $maxAge ); |
316 | 327 | } |
317 | 328 | } else { |
318 | 329 | $this->cache = false; //TODO: Kill this one in the face, too. (see above) |
— | — | @@ -341,12 +352,7 @@ |
342 | 353 | // make sure we have a session open for tracking a CSRF-prevention token |
343 | 354 | self::ensureSession(); |
344 | 355 | |
345 | | - if ( class_exists( $this->boss ) ) { |
346 | | - $g = $this->boss; |
347 | | - $gateway_ident = $g::getIdentifier(); |
348 | | - } else { |
349 | | - $gateway_ident = 'DonationData'; |
350 | | - } |
| 356 | + $gateway_ident = $this->gatewayID; |
351 | 357 | |
352 | 358 | if ( !isset( $_SESSION[$gateway_ident . 'EditToken'] ) ) { |
353 | 359 | // generate unsalted token to place in the session |
— | — | @@ -395,12 +401,8 @@ |
396 | 402 | * Unset the payflow edit token from a user's session |
397 | 403 | */ |
398 | 404 | function unsetEditToken() { |
399 | | - if ( class_exists( $this->boss ) ) { |
400 | | - $g = $this->boss; |
401 | | - $gateway_ident = $g::getIdentifier(); |
402 | | - } else { |
403 | | - $gateway_ident = "DonationData"; |
404 | | - } |
| 405 | + $gateway_ident = $this->gatewayID; |
| 406 | + |
405 | 407 | if ( isset( $_SESSION ) && isset( $_SESSION[$gateway_ident . 'EditToken'] ) ){ |
406 | 408 | unset( $_SESSION[$gateway_ident . 'EditToken'] ); |
407 | 409 | } |
— | — | @@ -425,10 +427,8 @@ |
426 | 428 | static $match = null; |
427 | 429 | |
428 | 430 | if ( $match === null ) { |
429 | | - if ( class_exists( $this->boss ) ) { |
430 | | - $g = $this->boss; |
431 | | - $salt = $g::getGlobal( 'Salt' ); |
432 | | - } else { |
| 431 | + $salt = $this->getGatewayGlobal( 'Salt' ); |
| 432 | + if ( $salt === false ){ |
433 | 433 | $salt = 'gotToBeInAUnitTest'; |
434 | 434 | } |
435 | 435 | |
— | — | @@ -713,6 +713,14 @@ |
714 | 714 | } |
715 | 715 | } |
716 | 716 | } |
| 717 | + |
| 718 | + function getAdapterClass(){ |
| 719 | + if ( class_exists( $this->boss ) ) { |
| 720 | + return $this->boss; |
| 721 | + } else { |
| 722 | + return false; |
| 723 | + } |
| 724 | + } |
717 | 725 | |
718 | 726 | } |
719 | 727 | |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -1147,6 +1147,11 @@ |
1148 | 1148 | |
1149 | 1149 | function runPreProcess() { |
1150 | 1150 | if ( $this->transaction_option( 'do_validation' ) ) { |
| 1151 | + if ( !isset( $wgHooks['GatewayValidate'] ) ) { |
| 1152 | + //if there ARE no validate hooks, we're okay. |
| 1153 | + $this->action = 'process'; |
| 1154 | + return; |
| 1155 | + } |
1151 | 1156 | // allow any external validators to have their way with the data |
1152 | 1157 | self::log( $this->getData( 'order_id' ) . " Preparing to query MaxMind" ); |
1153 | 1158 | wfRunHooks( 'GatewayValidate', array( &$this ) ); |