diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/color/color.module | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/color/color.module b/modules/color/color.module index f75f483eb..b6c43ef67 100644 --- a/modules/color/color.module +++ b/modules/color/color.module @@ -189,6 +189,23 @@ function color_scheme_form_submit($form_id, $values) { } } + // Make sure enough memory is available, if PHP's memory limit is compiled in. + if (function_exists('memory_get_usage')) { + // Fetch source image dimensions. + $source = drupal_get_path('theme', $theme) .'/'. $info['base_image']; + list($width, $height) = getimagesize($source); + + // We need at least a copy of the source and a target buffer of the same + // size (both at 32bpp). + $required = $width * $height * 8; + $usage = memory_get_usage(); + $limit = parse_size(ini_get('memory_limit')); + if ($usage + $required > $limit) { + drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the <a href="%url">PHP documentation</a> for more information.', array('%size' => format_size($usage + $required - $limit), '%url' => 'http://www.php.net/manual/en/ini.core.php#ini.sect.resource-limits')), 'error'); + return; + } + } + // Delete old files foreach (variable_get('color_'. $theme .'_files', array()) as $file) { @unlink($file); |