Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/232643
Change subject: Made MWTimestamp handle UNIX floats
......................................................................
Made MWTimestamp handle UNIX floats
* This avoids "wfTimestamp() fed bogus time value: TYPE=1;
VALUE=1440012118.9014" type
errors that show up in the debug log on page views, do to User::getTouched()
use.
Change-Id: I899d6edd2b59c02e618ed14f8d29dea53d866f05
---
M includes/MWTimestamp.php
M tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
2 files changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/43/232643/1
diff --git a/includes/MWTimestamp.php b/includes/MWTimestamp.php
index f2bd6ba..7df3bd6 100644
--- a/includes/MWTimestamp.php
+++ b/includes/MWTimestamp.php
@@ -56,9 +56,12 @@
*
* @since 1.20
*
- * @param bool|string $timestamp Timestamp to set, or false for current
time
+ * @param bool|string|int|float $timestamp Timestamp to set, or false
for current time
*/
public function __construct( $timestamp = false ) {
+ if ( is_float( $timestamp ) ) {
+ $timestamp = (int)$timestamp;
+ }
$this->setTimestamp( $timestamp );
}
diff --git a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
index bea496c..4ce51c6 100644
--- a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
@@ -21,6 +21,7 @@
array( -30281104, TS_MW, '19690115123456', 'Negative
TS_UNIX to TS_MW' ),
array( $t, TS_UNIX, 979562096, 'TS_UNIX to TS_UNIX' ),
array( $t, TS_DB, '2001-01-15 12:34:56', 'TS_UNIX to
TS_DB' ),
+ array( $t + .01, TS_MW, '20010115123456', 'TS_UNIX
float to TS_MW' ),
array( $t, TS_ISO_8601_BASIC, '20010115T123456Z',
'TS_ISO_8601_BASIC to TS_DB' ),
--
To view, visit https://gerrit.wikimedia.org/r/232643
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I899d6edd2b59c02e618ed14f8d29dea53d866f05
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits