From fedc2df4e5ec128e7a1cf0f8381c49300623f71d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 26 Dec 2010 20:39:21 +0000 Subject: [PATCH] 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.) --- includes/Exif.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 -- 2.20.1