Merge "wfTimestamp should not die on bogus input [Regression]"
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 15 Sep 2012 03:52:34 +0000 (03:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 15 Sep 2012 03:52:34 +0000 (03:52 +0000)
includes/GlobalFunctions.php
tests/phpunit/includes/media/BitmapMetadataHandlerTest.php

index 4080e46..17e3f4d 100644 (file)
@@ -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;
+       }
 }
 
 /**
index b604d59..88f87ef 100644 (file)
@@ -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 .