https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103416
Revision: 103416
Author: khorn
Date: 2011-11-16 23:41:59 +0000 (Wed, 16 Nov 2011)
Log Message:
-----------
GlobalCollect command-line orphan rectifier: More small tweaks.
Aside from taking care of some more notices that popped up when sending stomp
transactions, there is now a mechanism for looking up (and continually
re-asserting) the utm_source, pulled from the contribution_tracking database.
Modified Paths:
--------------
trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php
trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php
Modified:
trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php
===================================================================
---
trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php
2011-11-16 23:35:01 UTC (rev 103415)
+++
trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php
2011-11-16 23:41:59 UTC (rev 103416)
@@ -1,6 +1,8 @@
<?php
class GlobalCollectOrphanAdapter extends GlobalCollectAdapter {
+
+ protected $utm_source;
public function unstage_data( $data = array(), $final = true ){
$unstaged = array();
@@ -49,6 +51,11 @@
$this->defineReturnValueMap();
$this->stageData();
+
+ //have to do this here, or else.
+ $this->utm_source = $this->getUTMSourceFromDB();
+ $this->raw_data['utm_source'] = $this->utm_source;
+ $this->staged_data['utm_source'] = $this->utm_source;
}
public function addData($dataArray){
@@ -58,6 +65,8 @@
$this->raw_data['i_order_id'] = $order_id;
$this->staged_data['order_id'] = $order_id;
$this->staged_data['i_order_id'] = $order_id;
+ $this->raw_data['utm_source'] = $this->utm_source;
+ $this->staged_data['utm_source'] = $this->utm_source;
}
public function do_transaction($transaction){
@@ -66,8 +75,8 @@
case 'CANCEL_PAYMENT':
self::log($this->getData_Raw('contribution_tracking_id') . ": CVV: " .
$this->getData_Raw('cvv_result') . ": AVS: " .
$this->getData_Raw('avs_result'));
//and then go on, unless you're testing, in
which case:
- //return "NOPE";
- //break;
+// return "NOPE";
+// break;
default:
return parent::do_transaction($transaction);
break;
@@ -89,4 +98,35 @@
closelog();
}
+ public function getUTMSourceFromDB(){
+
+ $db =
ContributionTrackingProcessor::contributionTrackingConnection();
+
+ if ( !$db ) {
+ die("There is something terribly wrong with your
Contribution Tracking database. fixit.");
+ return null;
+ }
+
+ $ctid = $this->getData_Raw('contribution_tracking_id');
+
+ // if contrib tracking id is not already set, we need to insert
the data, otherwise update
+ if ( $ctid ) {
+ $res = $db->select( 'contribution_tracking',
+ array(
+ 'utm_source'
+ ),
+ array('id' => $ctid)
+ );
+ foreach ($res as $thing){
+ $this->log("$ctid: Found UTM Source value
$thing->utm_source");
+ return $thing->utm_source;
+ }
+ }
+
+ //if we got here, we can't find anything else...
+ $this->log("$ctid: FAILED to find UTM Source value. Using
default.");
+ return $this->getData_Raw('utm_source');
+
+ }
+
}
\ No newline at end of file
Modified:
trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php
===================================================================
---
trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php
2011-11-16 23:35:01 UTC (rev 103415)
+++
trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php
2011-11-16 23:41:59 UTC (rev 103416)
@@ -13,7 +13,7 @@
protected $killfiles = array();
protected $order_ids = array();
- protected $max_per_execute = 5;
+ protected $max_per_execute = 3;
function execute(){
@@ -48,6 +48,25 @@
$xml = new DomDocument;
+ //fields that have generated notices if they're not there.
+ $additional_fields = array(
+ 'card_num',
+ 'comment',
+ 'size',
+ 'utm_medium',
+ 'utm_campaign',
+ 'referrer',
+ 'mname',
+ 'fname2',
+ 'lname2',
+ 'street2',
+ 'city2',
+ 'state2',
+ 'country2',
+ 'zip2',
+ );
+
+
foreach ($payments as $key => $payment_data){
$xml->loadXML($payment_data['xml']);
$parsed = $adapter->getResponseData($xml);
@@ -55,9 +74,13 @@
$payments[$key]['unstaged'] =
$adapter->unstage_data($parsed);
$payments[$key]['unstaged']['contribution_tracking_id']
= $payments[$key]['contribution_tracking_id'];
$payments[$key]['unstaged']['i_order_id'] =
$payments[$key]['unstaged']['order_id'];
- $payments[$key]['unstaged']['card_num'] = '';
- }
-
+ 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.
@@ -70,6 +93,9 @@
unset($this->order_ids[$payments[$key]['unstaged']['order_id']]);
} else {
$adapter->log(
$payment_data['unstaged']['contribution_tracking_id'] . ": ERROR: " .
$results['message']);
+ if (strpos($results['message'],
"GET_ORDERSTATUS reports that the payment is already complete.")){
+
unset($this->order_ids[$payments[$key]['unstaged']['order_id']]);
+ }
}
echo $results['message'] . "\n";
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs