r103501 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103500‎ | r103501 | r103502 >
Date:20:17, 17 November 2011
Author:khorn
Status:ok
Tags:
Comment:
GlobalCollect command-line orphan rectifier: Fixing the loops that check that we haven't exceeded the max, and adding another max check to the main loop.
Modified paths:
  • /trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php
@@ -31,15 +31,14 @@
3232 $files = $this->getAllLogFileNames();
3333 $payments = array();
3434 foreach ($files as $file){
35 - if (count($payments) >= $this->max_per_execute){
36 - continue;
 35+ if (count($payments) < $this->max_per_execute){
 36+ $file_array = $this->getLogfileLines( $file );
 37+ $payments = array_merge($this->findTransactionLines($file_array), $payments);
 38+ if (count($payments) === 0){
 39+ $this->killfiles[] = $file;
 40+ echo print_r($this->killfiles, true);
 41+ }
3742 }
38 - $file_array = $this->getLogfileLines( $file );
39 - $payments = array_merge($this->findTransactionLines($file_array), $payments);
40 - if (count($payments) === 0){
41 - $this->killfiles[] = $file;
42 - echo print_r($this->killfiles, true);
43 - }
4443 }
4544
4645 $data = array(
@@ -89,19 +88,23 @@
9089 // Preferably *before* you rewrite the Order ID file.
9190
9291 //we may need to unset some hooks out here. Like... recaptcha. Makes no sense.
 92+ $i = 0;
9393 foreach($payments as $payment_data){
94 - $adapter->loadDataAndReInit($payment_data['unstaged']);
95 - $results = $adapter->do_transaction('Confirm_CreditCard');
96 - if ($results['status'] == true){
97 - $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": FINAL: " . $results['action']);
98 - unset($this->order_ids[$payment_data['unstaged']['order_id']]);
99 - } else {
100 - $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": ERROR: " . $results['message']);
101 - if (strpos($results['message'], "GET_ORDERSTATUS reports that the payment is already complete.")){
 94+ if ($i < $this->max_per_execute){
 95+ ++$i;
 96+ $adapter->loadDataAndReInit($payment_data['unstaged']);
 97+ $results = $adapter->do_transaction('Confirm_CreditCard');
 98+ if ($results['status'] == true){
 99+ $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": FINAL: " . $results['action']);
102100 unset($this->order_ids[$payment_data['unstaged']['order_id']]);
 101+ } else {
 102+ $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": ERROR: " . $results['message']);
 103+ if (strpos($results['message'], "GET_ORDERSTATUS reports that the payment is already complete.")){
 104+ unset($this->order_ids[$payment_data['unstaged']['order_id']]);
 105+ }
103106 }
 107+ echo $results['message'] . "\n";
104108 }
105 - echo $results['message'] . "\n";
106109 }
107110
108111 if ($outstanding_count != count($this->order_ids)){
@@ -138,16 +141,15 @@
139142
140143 $order_ids = $this->order_ids;
141144 foreach ($lines as $line_no=>$line_data){
142 - if (count($orders) >= $this->max_per_execute){
143 - continue;
144 - }
145 - $pos1 = strpos($line_data, '<ORDERID>') + 9;
146 - $pos2 = strpos($line_data, '</ORDERID>');
147 - if ($pos2 > $pos1){
148 - $tmp = substr($line_data, $pos1, $pos2-$pos1);
149 - if (isset($order_ids[$tmp])){
150 - $orders[$tmp] = trim($line_data);
151 - unset($order_ids[$tmp]);
 145+ if (count($orders) < $this->max_per_execute){
 146+ $pos1 = strpos($line_data, '<ORDERID>') + 9;
 147+ $pos2 = strpos($line_data, '</ORDERID>');
 148+ if ($pos2 > $pos1){
 149+ $tmp = substr($line_data, $pos1, $pos2-$pos1);
 150+ if (isset($order_ids[$tmp])){
 151+ $orders[$tmp] = trim($line_data);
 152+ unset($order_ids[$tmp]);
 153+ }
152154 }
153155 }
154156 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r103512MFT r103506, r103501, r103499, r103491, r103416, r103385, r103288, r103246, r...khorn21:54, 17 November 2011
r103513MFT r103506, r103501, r103499, r103491, r103416, r103385, r103288, r103246, r...khorn21:57, 17 November 2011
r105502MFT r103501, r103503, r104648, r104791, r104933khorn00:45, 8 December 2011

Status & tagging log