summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-11-04 01:43:41 -0500
committerDavid Rothstein <drothstein@gmail.com>2014-11-04 01:43:41 -0500
commitc8a26f2d06a54b80a491d658c437846251d0d5e6 (patch)
tree9b293379599b339f4b9aaa6eae73d416bf150b9b /modules
parent1b82c570504697f024cabba52fd34040d93ff19d (diff)
downloadbrdo-c8a26f2d06a54b80a491d658c437846251d0d5e6.tar.gz
brdo-c8a26f2d06a54b80a491d658c437846251d0d5e6.tar.bz2
Issue #927138 by manarth, handrus, rasmusluckow, douggreen, .John, Taz, David_Rothstein, droplet, webchick, marcingy: Fail image generation with 404 instead of 500, when source file is missing.
Diffstat (limited to 'modules')
-rw-r--r--modules/image/image.module6
-rw-r--r--modules/image/image.test10
2 files changed, 16 insertions, 0 deletions
diff --git a/modules/image/image.module b/modules/image/image.module
index 585c15a29..a2a0f416a 100644
--- a/modules/image/image.module
+++ b/modules/image/image.module
@@ -845,6 +845,12 @@ function image_style_deliver($style, $scheme) {
}
}
+ // Confirm that the original source image exists before trying to process it.
+ if (!is_file($image_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 MENU_NOT_FOUND;
+ }
+
// Don't start generating the image if the derivative already exists or if
// generation is in progress in another thread.
$lock_name = 'image_style_deliver:' . $style['name'] . ':' . drupal_hash_base64($image_uri);
diff --git a/modules/image/image.test b/modules/image/image.test
index 4a4aab055..2387314c5 100644
--- a/modules/image/image.test
+++ b/modules/image/image.test
@@ -174,6 +174,16 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase {
}
/**
+ * Test 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.');
+ }
+
+ /**
* Test image_style_url().
*/
function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FALSE) {