From 1b462e24f6565c6202c65f6fd2fcb2dcbdf7980e Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sat, 24 Sep 2016 00:59:56 +0100 Subject: [PATCH] Clean up misuse of wfTimestampOrNull() It's primarily meant for nullable timestamps in the database. And for the mere purpose of an is_null() check, it's more confusion than useful to cause this function since in these two cases its return value is not used as-is but further conditionalized. * Also fix fragile link between getRegistration()'s false return value never being passed to wfTimestamp (to mean "now") because of the isLoggedIn() guard. The ternary would now make those follow the 'else' branch toward null. Change-Id: I9a1ee2a56e1767bfb750e27b1f37bdaeb5e6378d --- includes/OutputPage.php | 4 ++-- includes/filerepo/ForeignAPIRepo.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index c57e219f8c..f5405d79e1 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3050,8 +3050,8 @@ class OutputPage extends ContextSource { if ( $user->isLoggedIn() ) { $vars['wgUserId'] = $user->getId(); $vars['wgUserEditCount'] = $user->getEditCount(); - $userReg = wfTimestampOrNull( TS_UNIX, $user->getRegistration() ); - $vars['wgUserRegistration'] = $userReg !== null ? ( $userReg * 1000 ) : null; + $userReg = $user->getRegistration(); + $vars['wgUserRegistration'] = $userReg ? wfTimestamp( TS_UNIX, $userReg ) * 1000 : null; // Get the revision ID of the oldest new message on the user's talk // page. This can be used for constructing new message alerts on // the client side. diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index 645a59bc16..4176c8240e 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -532,8 +532,8 @@ class ForeignAPIRepo extends FileRepo { $status = $req->execute(); if ( $status->isOK() ) { - $mtime = wfTimestampOrNull( TS_UNIX, $req->getResponseHeader( 'Last-Modified' ) ); - $mtime = $mtime ?: false; + $lmod = $req->getResponseHeader( 'Last-Modified' ); + $mtime = $lmod ? wfTimestamp( TS_UNIX, $lmod ) : false; return $req->getContent(); } else { -- 2.20.1