Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/205283
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, 10 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/83/205283/1
diff --git a/repo/includes/ChangePruner.php b/repo/includes/ChangePruner.php
index 6333c1a..58ff273 100644
--- a/repo/includes/ChangePruner.php
+++ b/repo/includes/ChangePruner.php
@@ -64,7 +64,7 @@
$this->messageReporter->reportMessage(
date( 'H:i:s' ) . " pruning entries older than "
- . wfTimestamp( TS_ISO_8601, $until )
+ . wfTimestamp( TS_ISO_8601, $until )
);
$affected = $this->pruneChanges( $until );
@@ -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: newchange
Gerrit-Change-Id: I7a7126e8ca4e369cf7a7058f634982fcb605ac9e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits