jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/331823 )

Change subject: Fix missing ct_id recovery
......................................................................


Fix missing ct_id recovery

We were returning a blank when there were no ct_ids on any associated
contributions. Don't return early if empty, and let the existing
backfill logic do its job.

Bug: T147873
Change-Id: Id6a9374260d6bbc4b73df90e3924cb6f38c6f198
---
M sites/all/modules/queue2civicrm/recurring/recurring.module
M sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
M sites/all/modules/wmf_civicrm/tracking.inc
3 files changed, 23 insertions(+), 3 deletions(-)

Approvals:
  jenkins-bot: Verified
  Eileen: Looks good to me, approved



diff --git a/sites/all/modules/queue2civicrm/recurring/recurring.module 
b/sites/all/modules/queue2civicrm/recurring/recurring.module
index 4b6588b..106e2b7 100644
--- a/sites/all/modules/queue2civicrm/recurring/recurring.module
+++ b/sites/all/modules/queue2civicrm/recurring/recurring.module
@@ -167,8 +167,10 @@
         $query = "SELECT id FROM {contribution_tracking} WHERE contribution_id 
IN ( {$id_list} )";
         // we can use this related contribution tracking id
         $contribution_tracking_id = db_query( $query )->fetchField();
-        watchdog( 'recurring', 'recurring_get_contribution_tracking_id: 
Selected contrib tracking id from past contributions, %cti', array( '%cti' => 
$contribution_tracking_id ), WATCHDOG_DEBUG );
-        return $contribution_tracking_id;
+        if ( !empty( $contribution_tracking_id ) ) {
+          watchdog( 'recurring', 'recurring_get_contribution_tracking_id: 
Selected contrib tracking id from past contributions, %cti', array( '%cti' => 
$contribution_tracking_id ), WATCHDOG_DEBUG );
+          return $contribution_tracking_id;
+        }
       }
     }
 
diff --git 
a/sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
 
b/sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
index 7bfada8..fcc4d59 100644
--- 
a/sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
+++ 
b/sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
@@ -186,4 +186,22 @@
                $this->assertTrue( $result->getCommunicationStatus() );
                $this->assertRegExp( '/SET_PAYMENT/', $result->getRawResponse() 
);
        }
+
+       /**
+        * Recover from missing ct_ids on all associated contributions
+        */
+       public function testBackfillContributionTracking() {
+               $id_list = implode( ',', $this->contributions );
+
+               $dbs = wmf_civicrm_get_dbs();
+               $dbs->push( 'donations' );
+               $query = "DELETE FROM {contribution_tracking} WHERE 
contribution_id IN( $id_list )";
+               db_query( $query );
+               $contribution_tracking_id = 
recurring_get_contribution_tracking_id( array(
+                       'txn_type' => 'subscr_payment',
+                       'subscr_id' => $this->subscriptionId,
+                       'payment_date' => strtotime( "now" ),
+               ) );
+               $this->assertNotEmpty( $contribution_tracking_id );
+       }
 }
diff --git a/sites/all/modules/wmf_civicrm/tracking.inc 
b/sites/all/modules/wmf_civicrm/tracking.inc
index 178af4f..6d7739c 100644
--- a/sites/all/modules/wmf_civicrm/tracking.inc
+++ b/sites/all/modules/wmf_civicrm/tracking.inc
@@ -7,7 +7,7 @@
  * particular transaction.  Rare, but inserting some data for a trxn when
  * absent helps facilitate better analytics.
  * 
- * @return the contribution_tracking id 
+ * @return int the contribution_tracking id
  */
 function wmf_civicrm_insert_contribution_tracking( $utm_source, $utm_medium, 
$utm_campaign, $ts, $contrib_id=null, $optout=null, $anonymous=null ) {
     // make sure we're using the default (drupal) db

-- 
To view, visit https://gerrit.wikimedia.org/r/331823
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id6a9374260d6bbc4b73df90e3924cb6f38c6f198
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Cdentinger <cdentin...@wikimedia.org>
Gerrit-Reviewer: Eileen <emcnaugh...@wikimedia.org>
Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to