r79024 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79023‎ | r79024 | r79025 >
Date:20:39, 26 December 2010
Author:brion
Status:ok
Tags:
Comment:
Throw an exception instead of low-level PHP fatal error if something invokes the Exif() class when exif functions aren't actually present. (Discovered with PagedTiffHandler enabled on my test machine.)
Modified paths:
  • /trunk/phase3/includes/Exif.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Exif.php
@@ -295,9 +295,13 @@
296296 $this->makeFlatExifTags();
297297
298298 $this->debugFile( $this->basename, __FUNCTION__, true );
299 - wfSuppressWarnings();
300 - $data = exif_read_data( $this->file );
301 - wfRestoreWarnings();
 299+ if( function_exists( 'exif_read_data' ) ) {
 300+ wfSuppressWarnings();
 301+ $data = exif_read_data( $this->file );
 302+ wfRestoreWarnings();
 303+ } else {
 304+ throw new MWException( "Internal error: exif_read_data not present. \$wgShowEXIF may be incorrectly set or not checked by an extension." );
 305+ }
302306 /**
303307 * exif_read_data() will return false on invalid input, such as
304308 * when somebody uploads a file called something.jpeg

Follow-up revisions

RevisionCommit summaryAuthorDate
r79025Check $wgShowEXIF before using Exif class; it's forced to false in DefaultSet...brion20:40, 26 December 2010

Status & tagging log