From: Brion Vibber Date: Sun, 26 Dec 2010 20:39:21 +0000 (+0000) Subject: Throw an exception instead of low-level PHP fatal error if something invokes the... X-Git-Tag: 1.31.0-rc.0~33077 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=fedc2df4e5ec128e7a1cf0f8381c49300623f71d;p=lhc%2Fweb%2Fwiklou.git 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.) --- diff --git a/includes/Exif.php b/includes/Exif.php index 630821c34b..a009199938 100644 --- a/includes/Exif.php +++ b/includes/Exif.php @@ -295,9 +295,13 @@ class Exif { $this->makeFlatExifTags(); $this->debugFile( $this->basename, __FUNCTION__, true ); - wfSuppressWarnings(); - $data = exif_read_data( $this->file ); - wfRestoreWarnings(); + if( function_exists( 'exif_read_data' ) ) { + wfSuppressWarnings(); + $data = exif_read_data( $this->file ); + wfRestoreWarnings(); + } else { + throw new MWException( "Internal error: exif_read_data not present. \$wgShowEXIF may be incorrectly set or not checked by an extension." ); + } /** * exif_read_data() will return false on invalid input, such as * when somebody uploads a file called something.jpeg