Ejegg has uploaded a new change for review.

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

Change subject: Don't default to now when no date found
......................................................................

Don't default to now when no date found

This logic could be re-used when determining whether to re-queue
messages in queue consumer error handling, but we don't want to
default to 'now' in that case.

Change-Id: I8785dc5a03f963a4165c5e02f60fdc2e88865746
---
M Core/DataStores/DamagedDatabase.php
M CrmLink/Messages/DateFields.php
2 files changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig 
refs/changes/17/316417/1

diff --git a/Core/DataStores/DamagedDatabase.php 
b/Core/DataStores/DamagedDatabase.php
index 8f6e60a..5253c92 100644
--- a/Core/DataStores/DamagedDatabase.php
+++ b/Core/DataStores/DamagedDatabase.php
@@ -28,8 +28,9 @@
                $trace = '',
                $retryDate = null
        ) {
+               $now = UtcDate::getUtcTimestamp();
                $originalDate = UtcDate::getUtcDatabaseString(
-                       DateFields::getOriginalDateOrNow( $message )
+                       DateFields::getOriginalDateOrDefault( $message, $now )
                );
 
                $dbRecord = array(
diff --git a/CrmLink/Messages/DateFields.php b/CrmLink/Messages/DateFields.php
index b30714a..4c6537f 100644
--- a/CrmLink/Messages/DateFields.php
+++ b/CrmLink/Messages/DateFields.php
@@ -7,10 +7,11 @@
 
        /**
         * @param array $message A message from donation queues
+        * @param int $default Value to return when message has no dates
         * @return int The unix timestamp at which the message was originally
-        *  enqueued, or the current timestamp if no date information exists
+        *  enqueued, or $default if no date information exists
         */
-       public static function getOriginalDateOrNow( $message ) {
+       public static function getOriginalDateOrDefault( $message, $default = 0 
) {
                // This is the actual queued time
                if ( isset( $message['source_enqueued_time'] ) ) {
                        // This is only ever set to the numeric timestamp
@@ -31,6 +32,6 @@
                                return $parsedTimestamp;
                        }
                }
-               return UtcDate::getUtcTimestamp();
+               return $default;
        }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8785dc5a03f963a4165c5e02f60fdc2e88865746
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
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