Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/314337

Change subject: Fix retry date calculation logic
......................................................................

Fix retry date calculation logic

Use source_enqueued_time where provided. TODO: provide everywhere.

Still FIXME: multiplying those two numbers is sketchy. Maybe add
back a retry_count field like the old stomp header?

Change-Id: I8f8af631d437ba94ae366bbf0cdf803629bebcea
---
M sites/all/modules/wmf_common/WmfQueueConsumer.php
1 file changed, 21 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/37/314337/1

diff --git a/sites/all/modules/wmf_common/WmfQueueConsumer.php 
b/sites/all/modules/wmf_common/WmfQueueConsumer.php
index 670dc6f..33131b4 100644
--- a/sites/all/modules/wmf_common/WmfQueueConsumer.php
+++ b/sites/all/modules/wmf_common/WmfQueueConsumer.php
@@ -2,6 +2,7 @@
 
 use SmashPig\Core\QueueConsumers\BaseQueueConsumer;
 use Exception;
+use SmashPig\PaymentProviders\Adyen\WSDL\issueNumber;
 use WmfException;
 
 /**
@@ -48,7 +49,26 @@
                        $delay = intval( variable_get( 
'wmf_common_requeue_delay', 20 * 60 ) );
                        $maxTries = intval( variable_get( 
'wmf_common_requeue_max', 10 ) );
                        $ageLimit = $delay * $maxTries;
-                       if ( $message['date'] + $ageLimit < time() ) {
+                       if ( isset( $message['source_enqueued_time'] ) ) {
+                               // This should be set the first time a message 
is queued and
+                               // not updated on retry.
+                               $queuedTime = $message['source_enqueued_time'];
+                       } else if ( isset( $message['date'] ) ) {
+                               // This is not entirely accurate, being the 
date the payment
+                               // actually occurred. Can still use it as 
fallback.
+                               $queuedTime = $message['date'];
+                       } else {
+                               // Setting this to 0 means we'll always go the 
reject route
+                               // and log an error.
+                               $queuedTime = 0;
+                               watchdog(
+                                       'wmf_common',
+                                       "Message has no useful information 
about queued date",
+                                       $message,
+                                       WATCHDOG_NOTICE
+                               );
+                       }
+                       if ( $queuedTime + $ageLimit < time() ) {
                                $reject = true;
                        } else {
                                $retryDate = time() + $delay;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f8af631d437ba94ae366bbf0cdf803629bebcea
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

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

Reply via email to