jenkins-bot has submitted this change and it was merged.
Change subject: Remove unused logfile parsing code
......................................................................
Remove unused logfile parsing code
It's dangerous to have a stale copy of this code... See the WR1 parser for a
happy ending.
Change-Id: I5e0d007915b87b3b8d3a3a8adcd30ea74c2f45b9
---
M globalcollect_gateway/scripts/orphans.php
1 file changed, 0 insertions(+), 181 deletions(-)
Approvals:
Ejegg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/globalcollect_gateway/scripts/orphans.php
b/globalcollect_gateway/scripts/orphans.php
index 1184e6a..5fed8e9 100644
--- a/globalcollect_gateway/scripts/orphans.php
+++ b/globalcollect_gateway/scripts/orphans.php
@@ -281,74 +281,6 @@
return $orphans;
}
- function parse_files(){
- //all the old stuff goes here.
- $order_ids = file( 'orphanlogs/order_ids.txt',
FILE_SKIP_EMPTY_LINES );
- foreach ( $order_ids as $key=>$val ){
- $order_ids[$key] = trim( $val );
- }
- foreach ( $order_ids as $id ){
- $this->order_ids[$id] = $id; //easier to unset this
way.
- }
- $outstanding_count = count( $this->order_ids );
- echo "Order ID count: $outstanding_count \n";
-
- $files = $this->getAllLogFileNames();
- $payments = array();
- foreach ( $files as $file ){
- if ( count( $payments ) < $this->max_per_execute ){
- $file_array = $this->getLogfileLines( $file );
- $payments = array_merge(
$this->findTransactionLines( $file_array ), $payments );
- if ( count( $payments ) === 0 ){
- $this->killfiles[] = $file;
- echo print_r( $this->killfiles, true );
- }
- }
- }
-
-
$this->adapter->setCurrentTransaction('INSERT_ORDERWITHPAYMENT');
- $xml = new DomDocument;
-
- //fields that have generated notices if they're not there.
- $additional_fields = array(
- 'card_num',
- 'utm_medium',
- 'utm_campaign',
- 'referrer',
- );
-
- foreach ($payments as $key => $payment_data){
- $xml->loadXML($payment_data['xml']);
- $parsed = $this->adapter->parseResponseData($xml);
- $payments[$key]['parsed'] = $parsed;
- $payments[$key]['unstaged'] =
$this->adapter->unstage_data($parsed);
- $payments[$key]['unstaged']['contribution_tracking_id']
= $payments[$key]['contribution_tracking_id'];
- foreach ($additional_fields as $val){
- if (!array_key_exists($val,
$payments[$key]['unstaged'])){
- $payments[$key]['unstaged'][$val] =
null;
- }
- }
- }
-
- // ADDITIONAL: log out what you did here, to... somewhere.
- // Preferably *before* you rewrite the Order ID file.
-
- //we may need to unset some hooks out here. Anything that
requires user interaction would make no sense here.
- $i = 0;
- foreach($payments as $payment_data){
- if ($i < $this->max_per_execute){
- ++$i;
- if ( $this->rectifyOrphan(
$payment_data['unstaged'] ) ) {
- unset(
$this->order_ids[$payment_data['unstaged']['order_id']] );
- }
- }
- }
-
- if ($outstanding_count != count($this->order_ids)){
- $this->rewriteOrderIds();
- }
- }
-
/**
* Uses the Orphan Adapter to rectify (complete the charge for) a
single orphan. Returns a boolean letting the caller know if
* the orphan has been fully rectified or not.
@@ -401,119 +333,6 @@
} else {
return NULL;
}
- }
-
- function getAllLogFileNames(){
- $files = array();
- if ($handle = opendir(__DIR__ . '/orphanlogs/')){
- while ( ($file = readdir($handle)) !== false ){
- if (trim($file, '.') != '' && $file !=
'order_ids.txt' && $file != '.svn'){
- $files[] = __DIR__ . '/orphanlogs/' .
$file;
- }
- }
- }
- closedir($handle);
- return $files;
- }
-
- function findTransactionLines($file){
- $lines = array();
- $orders = array();
- $contrib_id_finder = array();
- foreach ($file as $line_no=>$line_data){
- if (strpos($line_data,
'<XML><REQUEST><ACTION>INSERT_ORDERWITHPAYMENT') === 0){
- $lines[$line_no] = $line_data;
- } elseif (strpos($line_data, 'Raw XML Response')){
- $contrib_id_finder[] = $line_data;
- } elseif (strpos(trim($line_data), '<ORDERID>') === 0){
- $contrib_id_finder[] = trim($line_data);
- }
- }
-
- $order_ids = $this->order_ids;
- foreach ($lines as $line_no=>$line_data){
- if (count($orders) < $this->max_per_execute){
- $pos1 = strpos($line_data, '<ORDERID>') + 9;
- $pos2 = strpos($line_data, '</ORDERID>');
- if ($pos2 > $pos1){
- $tmp = substr($line_data, $pos1,
$pos2-$pos1);
- if (isset($order_ids[$tmp])){
- $orders[$tmp] =
trim($line_data);
- unset($order_ids[$tmp]);
- }
- }
- }
- }
-
- //reverse the array, so we find the last instance first.
- $contrib_id_finder = array_reverse($contrib_id_finder);
- foreach ($orders as $order_id => $xml){
- $finder = array_search("<ORDERID>$order_id</ORDERID>",
$contrib_id_finder);
-
- //now search forward (which is actually backward) to
the "Raw XML" line, so we can get the contribution_tracking_id
- //TODO: Some kind of (in)sanity check for this. Just
because we've found it one step backward doesn't mean...
- //...but it's kind of good. For now.
- $explode_me = false;
- while (!$explode_me){
- ++$finder;
- if (strpos($contrib_id_finder[$finder], "Raw
XML Response")){
- $explode_me =
$contrib_id_finder[$finder];
- }
- }
- if (strlen($explode_me)){
- $explode_me = explode(': ', $explode_me);
- $contribution_tracking_id =
trim($explode_me[1]);
- $orders[$order_id] = array(
- 'xml' => $xml,
- 'contribution_tracking_id' =>
$contribution_tracking_id,
- );
- }
- }
-
- return $orders;
- }
-
- function rewriteOrderIds() {
- $file = fopen('orphanlogs/order_ids.txt', 'w');
- $outstanding_orders = implode("\n", $this->order_ids);
- fwrite($file, $outstanding_orders);
- fclose($file);
- }
-
- function getLogfileLines( $file ){
- $array = file($file, FILE_SKIP_EMPTY_LINES);
- //now, check about 50 lines to make sure we're not seeing any
of that #012, #015 crap.
- $checkcount = 50;
- if (count($array) < $checkcount){
- $checkcount = count($array);
- }
- $convert = false;
- for ($i=0; $i<$checkcount; ++$i){
- if( strpos($array[$i], '#012') || strpos($array[$i],
'#015') ){
- $convert = true;
- break;
- }
- }
- if ($convert) {
- $array2 = array();
- foreach ($array as $line){
- if (strpos($line, '#012')){
- $line = str_replace('#012', "\n",
$line);
- }
- if (strpos($line, '#015') ){
- $line = str_replace('#015', "\r",
$line);
- }
- $array2[] = $line;
- }
- $newfile = implode("\n", $array2);
-
- $handle = fopen($file, 'w');
- fwrite($handle, $newfile);
- fclose($handle);
- $array = file($file, FILE_SKIP_EMPTY_LINES);
- }
-
- return $array;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/207742
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5e0d007915b87b3b8d3a3a8adcd30ea74c2f45b9
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits