Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -107,6 +107,7 @@ |
108 | 108 | * Do not try to group together a page creation and edit in the RSS feed of RC. |
109 | 109 | * (bug 29342) Patrol preferences shouldn't be visible to users who don't have |
110 | 110 | patrol permissions |
| 111 | +* (bug 29471) Exception thrown for files with invalid date in metadata |
111 | 112 | |
112 | 113 | === API changes in 1.19 === |
113 | 114 | * BREAKING CHANGE: action=watch now requires POST and token. |
Index: trunk/phase3/tests/phpunit/includes/media/FormatMetadataTest.php |
— | — | @@ -0,0 +1,23 @@ |
| 2 | +<?php |
| 3 | +class FormatMetadataTest extends MediaWikiTestCase { |
| 4 | + public function testInvalidDate() { |
| 5 | + $file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) . |
| 6 | + '/broken_exif_date.jpg', 'image/jpeg' ); |
| 7 | + |
| 8 | + // Throws an error if bug hit |
| 9 | + $meta = $file->formatMetadata(); |
| 10 | + |
| 11 | + // Find date exif entry |
| 12 | + $this->assertArrayHasKey( 'visible', $meta ); |
| 13 | + $dateIndex = null; |
| 14 | + foreach ( $meta['visible'] as $i => $data ) { |
| 15 | + if ( $data['id'] == 'exif-datetimeoriginal' ) { |
| 16 | + $dateIndex = $i; |
| 17 | + } |
| 18 | + } |
| 19 | + $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' ); |
| 20 | + $this->assertEquals( '0000:01:00 00:02:27', |
| 21 | + $meta['visible'][$dateIndex]['value'], |
| 22 | + 'File with invalid date metadata (bug 29471)' ); |
| 23 | + } |
| 24 | +} |
\ No newline at end of file |
Property changes on: trunk/phase3/tests/phpunit/includes/media/FormatMetadataTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 25 | + native |
Index: trunk/phase3/tests/phpunit/includes/media/broken_exif_date.jpg |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/phase3/tests/phpunit/includes/media/broken_exif_date.jpg |
___________________________________________________________________ |
Added: svn:mime-type |
2 | 26 | + application/octet-stream |
Index: trunk/phase3/includes/media/FormatMetadata.php |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | |
106 | 106 | $time = wfTimestamp( TS_MW, '1971:01:01 ' . $tags[$tag] ); |
107 | 107 | // the 1971:01:01 is just a placeholder, and not shown to user. |
108 | | - if ( $time ) { |
| 108 | + if ( $time && intval( $time ) > 0 ) { |
109 | 109 | $tags[$tag] = $wgLang->time( $time ); |
110 | 110 | } |
111 | 111 | continue; |
— | — | @@ -234,7 +234,7 @@ |
235 | 235 | $val = wfMsg( 'exif-unknowndate' ); |
236 | 236 | } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d) (?:\d\d):(?:\d\d):(?:\d\d)$/D', $val ) ) { |
237 | 237 | $time = wfTimestamp( TS_MW, $val ); |
238 | | - if ( $time ) { |
| 238 | + if ( $time && intval( $time ) > 0 ) { |
239 | 239 | $val = $wgLang->timeanddate( $time ); |
240 | 240 | } |
241 | 241 | } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d)$/D', $val ) ) { |
— | — | @@ -243,7 +243,7 @@ |
244 | 244 | . substr( $val, 5, 2 ) |
245 | 245 | . substr( $val, 8, 2 ) |
246 | 246 | . '000000' ); |
247 | | - if ( $time ) { |
| 247 | + if ( $time && intval( $time ) > 0 ) { |
248 | 248 | $val = $wgLang->date( $time ); |
249 | 249 | } |
250 | 250 | } |