Skip to content
Snippets Groups Projects
Commit f816c891 authored by Alex Pott's avatar Alex Pott
Browse files

Issue follow-up #927138 by manarth, handrus, David_Rothstein: Fail image...

Issue follow-up #927138 by manarth, handrus, David_Rothstein: Fail image generation with 404 instead of 500, when source file is missing.
parent 951601cb
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -562,7 +562,7 @@ function image_style_deliver($style, $scheme) {
// Don't try to generate file if source is missing.
if (!file_exists($image_uri)) {
watchdog('image', 'Unable to generate the derived image from image at %path.', array('%path' => $derivative_uri));
watchdog('image', 'Source image at %source_image_path not found while trying to generate derivative image at %derivative_path.', array('%source_image_path' => $image_uri, '%derivative_path' => $derivative_uri));
return new Response(t('Error generating image, missing source file.'), 404);
}
......
......@@ -90,6 +90,16 @@ function testImageStyleUrlExtraSlash() {
$this->_testImageStyleUrlAndPath('public', TRUE, TRUE);
}
/**
* Tests that an invalid source image returns a 404.
*/
function testImageStyleUrlForMissingSourceImage() {
$non_existent_uri = 'public://foo.png';
$generated_url = image_style_url($this->style_name, $non_existent_uri);
$this->drupalGet($generated_url);
$this->assertResponse(404, 'Accessing an image style URL with a source image that does not exist provides a 404 error response.');
}
/**
* Tests image_style_url().
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment