From: umherirrender Date: Fri, 14 Sep 2012 16:28:22 +0000 (+0200) Subject: wfTimestamp should not die on bogus input [Regression] X-Git-Tag: 1.31.0-rc.0~22378^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=99159fd750eabc37032aa5111ebc6c79c054663a;p=lhc%2Fweb%2Fwiklou.git wfTimestamp should not die on bogus input [Regression] Followup I68eb9f27 No caller of wfTimestamp can handle the exception, false is always used, as the method comment says. See bug 40037 for File related timestamps. The api result is also not b/c: Change-Id: I1e8c785941d35678f3d12824bdde0ce245572592 --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 4080e466ab..17e3f4d5a0 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2409,8 +2409,13 @@ define( 'TS_ISO_8601_BASIC', 9 ); * @return Mixed: String / false The same date in the format specified in $outputtype or false */ function wfTimestamp( $outputtype = TS_UNIX, $ts = 0 ) { - $timestamp = new MWTimestamp( $ts ); - return $timestamp->getTimestamp( $outputtype ); + try { + $timestamp = new MWTimestamp( $ts ); + return $timestamp->getTimestamp( $outputtype ); + } catch( TimestampException $e ) { + wfDebug("wfTimestamp() fed bogus time value: TYPE=$outputtype; VALUE=$ts\n"); + return false; + } } /** diff --git a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php index b604d59041..88f87ef9e3 100644 --- a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php +++ b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php @@ -76,7 +76,6 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase { /** * File has an invalid time (+ one valid but really weird time) * that shouldn't be included - * @expectedException TimestampException */ public function testIPTCDatesInvalid() { $meta = BitmapMetadataHandler::Jpeg( $this->filePath .