Ejegg has submitted this change and it was merged. Change subject: Handle dates more carefully in recurring messages ......................................................................
Handle dates more carefully in recurring messages The message timestamp on subscription signup messages was being set incorrectly to the current time or the payment date. This wouldn't have corrupted data, because the timestamp is not stored nor used for currency conversion, but it was a problem for tests where the currency is mocked by exact time. Change-Id: I04fe4365d8933d714b96a13af07ad864c7017897 --- M sites/all/modules/queue2civicrm/recurring/recurring.module 1 file changed, 10 insertions(+), 3 deletions(-) Approvals: Ejegg: Looks good to me, approved jenkins-bot: Verified diff --git a/sites/all/modules/queue2civicrm/recurring/recurring.module b/sites/all/modules/queue2civicrm/recurring/recurring.module index 2ebf20d..6d6d302 100644 --- a/sites/all/modules/queue2civicrm/recurring/recurring.module +++ b/sites/all/modules/queue2civicrm/recurring/recurring.module @@ -497,7 +497,9 @@ function recurring_normalize_paypal_msg( $msg ) { $msg_normalized = array(); - $timestamp = ( !isset( $msg[ 'payment_date' ] ) || !strlen( $msg[ 'payment_date' ] )) ? strtotime( "now" ) : strtotime( $msg[ 'payment_date' ] ); + if ( isset( $msg['payment_date'] ) ) { + $msg_normalized['date'] = strtotime( $msg['payment_date'] ); + } // the subscription id $msg_normalized[ 'subscr_id' ] = $msg[ 'subscr_id' ]; @@ -612,8 +614,11 @@ } elseif( $msg[ 'txn_type' ] == 'subscr_cancel' ) { $msg_normalized[ 'cancel_date' ] = strtotime( $msg[ 'subscr_date' ] ); } + if ( !isset( $msg_normalized['date'] ) ) { + $msg_normalized['date'] = strtotime( $msg['subscr_date'] ); + } } - + if ( $msg[ 'txn_type' ] == 'subscr_modify' ) { $msg_normalized[ 'modified_date' ] = $msg[ 'subscr_effective' ]; } @@ -631,7 +636,9 @@ $msg_normalized[ 'gateway' ] = ( !empty( $msg['gateway'] ) ? $msg['gateway'] : 'paypal' ); - $msg_normalized[ 'date' ] = $timestamp; + if ( !isset( $msg_normalized['date'] ) ) { + $msg_normalized['date'] = time(); + } // FIXME: so dirty. foreach ( $msg as $key => $value ) { -- To view, visit https://gerrit.wikimedia.org/r/195050 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I04fe4365d8933d714b96a13af07ad864c7017897 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com> Gerrit-Reviewer: Awight <awi...@wikimedia.org> Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org> Gerrit-Reviewer: Katie Horn <kh...@wikimedia.org> Gerrit-Reviewer: Ssmith <ssm...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits