jenkins-bot has submitted this change and it was merged.

Change subject: Fix 32 bit integer overflow in ChangePrunerTest
......................................................................


Fix 32 bit integer overflow in ChangePrunerTest

Look at the intval() I removed. This casted a MediaWiki timestamp
string to integer instead of applying wfTimestamp( TS_UNIX, ...).
This is an actual bug and should have failed on all machines but only
failed in my local 32 bit PHP.

In this patch I'm changing most methods to not get and return integer
timestamps, but MediaWiki timestamp strings instead.

Bug: T96566
Change-Id: I7a7126e8ca4e369cf7a7058f634982fcb605ac9e
---
M repo/includes/ChangePruner.php
1 file changed, 9 insertions(+), 8 deletions(-)

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



diff --git a/repo/includes/ChangePruner.php b/repo/includes/ChangePruner.php
index 6333c1a..91946e2 100644
--- a/repo/includes/ChangePruner.php
+++ b/repo/includes/ChangePruner.php
@@ -80,7 +80,8 @@
        /**
         * Calculates the timestamp up to which changes can be pruned.
         *
-        * @return int Timestamp up to which changes can be pruned (as Unix 
period).
+        * @return string Timestamp up to which changes can be pruned (as 
MediaWiki concatenated string
+        * timestamp).
         */
        private function getCutoffTimestamp() {
                $until = time() - $this->keepSeconds;
@@ -104,23 +105,23 @@
                        }
                }
 
-               return $this->limitCutoffTimestamp( $until );
+               return $this->limitCutoffTimestamp( wfTimestamp( TS_MW, $until 
) );
        }
 
        /**
         * Changes the cutoff timestamp to not affect more than $this->batchSize
         * rows, if needed.
         *
-        * @param int $until
+        * @param string $until MediaWiki concatenated string timestamp
         *
-        * @return int
+        * @return string MediaWiki concatenated string timestamp
         */
        private function limitCutoffTimestamp( $until ) {
                $dbr = wfGetDB( DB_SLAVE );
                $changeTime = $dbr->selectField(
                        'wb_changes',
                        'change_time',
-                       array( 'change_time < ' . $dbr->addQuotes( wfTimestamp( 
TS_MW, $until ) ) ),
+                       array( 'change_time < ' . $dbr->addQuotes( $until ) ),
                        __METHOD__,
                        array(
                                'OFFSET' => $this->batchSize,
@@ -128,13 +129,13 @@
                        )
                );
 
-               return $changeTime ? intval( $changeTime ) : $until;
+               return $changeTime ?: $until;
        }
 
        /**
         * Prunes all changes older than $until from the changes table.
         *
-        * @param int $until
+        * @param string $until MediaWiki concatenated string timestamp
         *
         * @return int the number of changes deleted.
         */
@@ -143,7 +144,7 @@
 
                $dbw->delete(
                        'wb_changes',
-                       array( 'change_time < ' . $dbw->addQuotes( wfTimestamp( 
TS_MW, $until ) ) ),
+                       array( 'change_time < ' . $dbw->addQuotes( $until ) ),
                        __METHOD__
                );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7a7126e8ca4e369cf7a7058f634982fcb605ac9e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to