r103513 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103512‎ | r103513 | r103514 >
Date:21:57, 17 November 2011
Author:khorn
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/functions/functions.body.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/minfraud.body.php (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)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
@@ -41,7 +41,6 @@
4242 $this->risk_score = 0;
4343 if ( $this->risk_score > 100 )
4444 $this->risk_score = 100;
45 -// error_log("Risk score: " . $this->risk_score );
4645 foreach ( $this->action_ranges as $action => $range ) {
4746 if ( $this->risk_score >= $range[0] && $this->risk_score <= $range[1] ) {
4847 return $action;
@@ -73,7 +72,7 @@
7473 }
7574
7675 static function singleton( &$gateway_adapter ) {
77 - if ( !self::$instance ) {
 76+ if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) {
7877 self::$instance = new self( $gateway_adapter );
7978 }
8079 return self::$instance;
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
___________________________________________________________________
Modified: svn:mergeinfo
8180 Merged /trunk/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php:r103024,103076,103246,103288,103385,103416,103491,103499,103501,103506
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php
@@ -56,7 +56,7 @@
5757 }
5858
5959 static function singleton( &$gateway_adapter, &$custom_filter_object ) {
60 - if ( !self::$instance ) {
 60+ if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) {
6161 self::$instance = new self( $gateway_adapter, $custom_filter_object );
6262 }
6363 return self::$instance;
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php
@@ -37,7 +37,7 @@
3838 }
3939
4040 static function singleton( &$gateway_adapter ) {
41 - if ( !self::$instance ) {
 41+ if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) {
4242 self::$instance = new self( $gateway_adapter );
4343 }
4444 return self::$instance;
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/functions/functions.body.php
@@ -54,7 +54,7 @@
5555 }
5656
5757 static function singleton( &$gateway_adapter, &$custom_filter_object ) {
58 - if ( !self::$instance ) {
 58+ if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) {
5959 self::$instance = new self( $gateway_adapter, $custom_filter_object );
6060 }
6161 return self::$instance;
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php
@@ -56,7 +56,7 @@
5757 }
5858
5959 static function singleton( &$gateway_adapter, &$custom_filter_object ) {
60 - if ( !self::$instance ) {
 60+ if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) {
6161 self::$instance = new self( $gateway_adapter, $custom_filter_object );
6262 }
6363 return self::$instance;
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/minfraud.body.php
@@ -112,7 +112,7 @@
113113 public function can_bypass_minfraud() {
114114 // if the data bits data_hash and action are not set, we need to hit minFraud
115115 $localdata = $this->gateway_adapter->getData_Raw();
116 - if ( !strlen( $localdata['data_hash'] ) || !strlen( $localdata['action'] ) ) {
 116+ if ( !isset($localdata['data_hash']) || !strlen( $localdata['data_hash'] ) || !isset($localdata['action']) || !strlen( $localdata['action'] ) ) {
117117 return FALSE;
118118 }
119119
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras
___________________________________________________________________
Modified: svn:mergeinfo
120120 Merged /trunk/extensions/DonationInterface/extras:r103024,103076,103246,103288,103385,103416,103491,103499,103501,103506
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -976,22 +976,50 @@
977977 $addme[$ourkey] = $tmp;
978978 }
979979 }
980 - if ( count( $addme ) ){
 980+
 981+ $post_status_check = false;
 982+ if ( count( $addme ) ){ //nothing unusual here.
981983 $this->addData( $addme );
 984+ $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': ';
 985+ $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' );
 986+ $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' );
 987+ self::log( $logmsg );
 988+ } else { //this is an orphan transaction.
 989+ $this->staged_data['order_id'] = $this->staged_data['i_order_id'];
 990+ $post_status_check = true;
982991 }
983 - $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': ';
984 - $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' );
985 - $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' );
986 - self::log( $logmsg );
987992
988993 $status_result = $this->do_transaction( 'GET_ORDERSTATUS' );
989994
990 - //error_log( "GET_ORDERSTATUS result: " . $status_result );
991 -
992995 $cancelflag = false; //this will denote the thing we're trying to do with the donation attempt
993996 $problemflag = false; //this will get set to true, if we can't continue and need to give up and just log the hell out of it.
994997 $problemmessage = ''; //to be used in conjunction with the flag.
 998+
995999
 1000+ if ( $post_status_check ){
 1001+ if ( array_key_exists('data', $status_result) ) {
 1002+ foreach ( $pull_vars as $theirkey => $ourkey) {
 1003+ if ( array_key_exists($theirkey, $status_result['data']) ) {
 1004+ $addme[$ourkey] = $status_result['data'][$theirkey];
 1005+ }
 1006+ }
 1007+ }
 1008+
 1009+ if ( count( $addme ) ){
 1010+ $this->addData( $addme );
 1011+ $this->staged_data['order_id'] = $this->staged_data['i_order_id'];
 1012+ $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': ';
 1013+ $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' );
 1014+ $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' );
 1015+ self::log( $logmsg );
 1016+ $this->runPreProcessHooks();
 1017+ $status_result['action'] = $this->getValidationAction();
 1018+ } else {
 1019+ $problemflag = true; //nothing to be done.
 1020+ $problemmessage = "Unable to retrieve orphan cvv/avs results (Communication problem?).";
 1021+ }
 1022+ }
 1023+
9961024 //we filtered
9971025 if ( array_key_exists( 'action', $status_result ) && $status_result['action'] != 'process' ){
9981026 $cancelflag = true;
@@ -1014,9 +1042,13 @@
10151043 case 'revised' :
10161044 $cancelflag = true; //makes sure we don't try to confirm.
10171045 break;
1018 - }
 1046+ case 'complete' :
 1047+ $problemflag = true; //nothing to be done.
 1048+ $problemmessage = "GET_ORDERSTATUS reports that the payment is already complete.";
 1049+ break;
 1050+ }
10191051 }
1020 -
 1052+
10211053 //if we got here with no problemflag,
10221054 //confirm or cancel the payment based on $cancelflag
10231055 if ( !$problemflag ){
@@ -1194,7 +1226,9 @@
11951227 break;
11961228 case 'GET_ORDERSTATUS':
11971229 $data = $this->xmlChildrenToArray( $response, 'STATUS' );
1198 - $this->setTransactionWMFStatus( $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ) );
 1230+ if (isset($data['STATUSID'])){
 1231+ $this->setTransactionWMFStatus( $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ) );
 1232+ }
11991233 $data['ORDER'] = $this->xmlChildrenToArray( $response, 'ORDER' );
12001234 break;
12011235 }
@@ -1548,23 +1582,34 @@
15491583 protected function stage_language( $type = 'request' ) {
15501584 $language = strtolower( $this->staged_data['language'] );
15511585
1552 - $count = 0;
1553 - //Count's just there making sure we don't get stuck here.
1554 - while ( !in_array( $language, $this->getAvailableLanguages() ) && $count < 3 ){
1555 - // Get the fallback language
1556 - $language = Language::getFallbackFor( $language );
1557 - $count += 1;
 1586+ switch ( $type ) {
 1587+ case 'request':
 1588+ $count = 0;
 1589+ //Count's just there making sure we don't get stuck here.
 1590+ while ( !in_array( $language, $this->getAvailableLanguages() ) && $count < 3 ){
 1591+ // Get the fallback language
 1592+ $language = Language::getFallbackFor( $language );
 1593+ $count += 1;
 1594+ }
 1595+
 1596+ if ( !in_array( $language, $this->getAvailableLanguages() ) ){
 1597+ $language = 'en';
 1598+ }
 1599+
 1600+ if ( $language === 'zh' ) { //Handles GC's mutant Chinese code.
 1601+ $language = 'sc';
 1602+ }
 1603+
 1604+ break;
 1605+ case 'response':
 1606+ if ( $language === 'sc' ){
 1607+ $language = 'zh';
 1608+ }
 1609+ break;
15581610 }
15591611
1560 - if ( !in_array( $language, $this->getAvailableLanguages() ) ){
1561 - $language = 'en';
1562 - }
1563 -
1564 - if ( $language === 'zh' ) { //Handles GC's mutant Chinese code.
1565 - $language = 'sc';
1566 - }
1567 -
15681612 $this->staged_data['language'] = $language;
 1613+
15691614 }
15701615
15711616 /**
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -162,6 +162,7 @@
163163 protected $current_transaction;
164164 protected $action;
165165 public $debugarray;
 166+ protected $batch = false;
166167
167168 //ALL OF THESE need to be redefined in the children. Much voodoo depends on the accuracy of these constants.
168169 const GATEWAY_NAME = 'Donation Gateway';
@@ -194,24 +195,26 @@
195196 extract( $options );
196197
197198 $testData = isset( $testData ) ? $testData : false;
 199+ $external_data = isset( $external_data ) ? $external_data : false; //not test data: Regular type.
198200 $postDefaults = isset( $postDefaults ) ? $postDefaults : false;
199 -
 201+
200202 if ( !self::getGlobal( 'Test' ) ) {
201203 $this->url = self::getGlobal( 'URL' );
202 -
203204 // Only submit test data if we are in test mode.
204 - $testData = false;
205205 } else {
206206 $this->url = self::getGlobal( 'TestingURL' );
 207+ if ( $testData ){
 208+ $external_data = $testData;
 209+ }
207210 }
 211+
 212+ $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ), $external_data );
208213
209 - $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ), $testData );
210 -
211214 $this->raw_data = $this->dataObj->getData();
212215 $this->staged_data = $this->raw_data;
 216+
 217+ $this->posted = ( $this->dataObj->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) );
213218
214 - $this->posted = ( $wgRequest->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) );
215 -
216219 $this->setPostDefaults( $postDefaults );
217220 $this->defineTransactions();
218221 $this->defineErrorMap();
@@ -1653,7 +1656,7 @@
16541657 * @return mixed Transaction results status, or false if not set.
16551658 */
16561659 public function getTransactionStatus() {
1657 - if ( array_key_exists( 'status', $this->transaction_results ) ) {
 1660+ if ( is_array( $this->transaction_results ) && array_key_exists( 'status', $this->transaction_results ) ) {
16581661 return $this->transaction_results['status'];
16591662 } else {
16601663 return false;
@@ -1973,5 +1976,18 @@
19741977 public function hasDonorDataInSession( $key = false, $value= '' ){
19751978 return $this->dataObj->hasDonorDataInSession( $key, $value );
19761979 }
 1980+
 1981+ /**
 1982+ * Lets the outside world (particularly hooks that accumulate points scores)
 1983+ * know if we are a batch processor.
 1984+ * @return type
 1985+ */
 1986+ public function isBatchProcessor(){
 1987+ if (!property_exists($this, 'batch')){
 1988+ return false;
 1989+ } else {
 1990+ return $this->batch;
 1991+ }
 1992+ }
19771993
19781994 }
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
@@ -101,7 +101,7 @@
102102 'iban' => $wgRequest->getText( 'iban', null ),
103103 'transaction_type' => $wgRequest->getText( 'transaction_type', null ),
104104 );
105 - if ( !$wgRequest->wasPosted() ) {
 105+ if ( !$this->wasPosted() ) {
106106 $this->setVal( 'posted', false );
107107 }
108108 }
@@ -1004,6 +1004,23 @@
10051005 );
10061006 return $stomp_fields;
10071007 }
 1008+
 1009+ /**
 1010+ * Basically, this is a wrapper for the $wgRequest wasPosted function that
 1011+ * won't give us notices if we weren't even a web request.
 1012+ * I realize this is pretty lame.
 1013+ * Notices, however, are more lame.
 1014+ * @global type $wgRequest
 1015+ * @staticvar string $posted Keeps track so we don't have to figure it out twice.
 1016+ */
 1017+ public function wasPosted(){
 1018+ global $wgRequest;
 1019+ static $posted = null;
 1020+ if ($posted === null){
 1021+ $posted = (array_key_exists('REQUEST_METHOD', $_SERVER) && $wgRequest->wasPosted());
 1022+ }
 1023+ return $posted;
 1024+ }
10081025 }
10091026
10101027 ?>
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
___________________________________________________________________
Modified: svn:mergeinfo
10111028 Merged /trunk/extensions/DonationInterface/gateway_common/DonationData.php:r103024,103076,103246,103288,103385,103416,103491,103499,103501,103506

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103024Preliminary steps toward a command-line solution for finding donations which ...khorn20:43, 14 November 2011
r103076More (but still preliminary) work toward a command-line solution for finding ...khorn23:35, 14 November 2011
r103246Lots more work on the GlobalCollect command-line orphan rectifier....khorn22:23, 15 November 2011
r103288GlobalCollect command-line orphan rectifier: Very near completion. (Intention...khorn02:18, 16 November 2011
r103385GlobalCollect command-line orphan rectifier: As near as I can tell, the first...khorn21:19, 16 November 2011
r103416GlobalCollect command-line orphan rectifier: More small tweaks....khorn23:41, 16 November 2011
r103491GlobalCollect command-line orphan rectifier: Adding in yet more data from the...khorn18:57, 17 November 2011
r103499GlobalCollect command-line orphan rectifier: Bugfix, because I'm hella dumb.khorn19:34, 17 November 2011
r103501GlobalCollect command-line orphan rectifier: Fixing the loops that check that...khorn20:17, 17 November 2011
r103506GlobalCollect command-line orphan rectifier: addressing r103288 fixme.khorn20:35, 17 November 2011

Status & tagging log