Skip to content

Commit aac0b4d

Browse files
committed
Changed image_graphicsmagick_toolkit_get_info() to log the thrown exceptions
1 parent 68a4ba5 commit aac0b4d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

graphicsmagick.module

+5-1
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,17 @@ function image_graphicsmagick_toolkit_get_info(object $image): false|array {
318318
$details['width'] = $handler->imageWidth();
319319
$details['height'] = $handler->imageHeight();
320320
}
321-
catch (GmagickException) {
321+
catch (InvalidArgumentException | Error $e) {
322322
// An exception has been thrown when trying to access the image information,
323323
// which could also mean the image file is corrupted. Return FALSE to signal
324324
// an error.
325+
watchdog_exception('graphicsmagick', $e);
326+
325327
return FALSE;
326328
}
327329

330+
$image->handler = NULL;
331+
328332
return $details;
329333
}
330334

includes/image_handler.class.inc

+13
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ class ImageHandler {
7575
return file_unmanaged_copy($source, $destination, FILE_EXISTS_REPLACE);
7676
}
7777

78+
/**
79+
* Creates the image handler.
80+
*
81+
* @param object $image
82+
* An image object. The $image->handler value will be set by this call.
83+
*
84+
* @return $this|null
85+
* The image handler or NULL if the image could not be loaded.
86+
*
87+
* @throws InvalidArgumentException
88+
* $image->handler is not NULL nor an instance of the current class.
89+
* $image->source is not a string.
90+
*/
7891
public static function create(object $image): ?self {
7992
if (isset($image->handler) && !is_a($image->handler, self::class)) {
8093
throw new InvalidArgumentException('The image handler must be an instance of ' . self::class . '.');

0 commit comments

Comments
 (0)