From b7725e30c2455c848894171bba999fbe2c56d2bf Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 11 May 2012 09:30:23 +0800 Subject: [PATCH] MDL-32914 fixed function get_imageinfo() to get rid of notice messages --- lib/filestorage/stored_file.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/filestorage/stored_file.php b/lib/filestorage/stored_file.php index 2457f86e9891c..6d6f29411fbd4 100644 --- a/lib/filestorage/stored_file.php +++ b/lib/filestorage/stored_file.php @@ -407,7 +407,14 @@ public function archive_file(file_archive $filearch, $archivepath) { * @return mixed array with width, height and mimetype; false if not an image */ public function get_imageinfo() { - if (!$imageinfo = getimagesize($this->get_content_file_location())) { + $path = $this->get_content_file_location(); + if (!is_readable($path)) { + if (!$this->fs->try_content_recovery($this) or !is_readable($path)) { + throw new file_exception('storedfilecannotread', '', $path); + } + } + $mimetype = $this->get_mimetype(); + if (!preg_match('|^image/|', $mimetype) || !filesize($path) || !($imageinfo = getimagesize($path))) { return false; } $image = array('width'=>$imageinfo[0], 'height'=>$imageinfo[1], 'mimetype'=>image_type_to_mime_type($imageinfo[2]));