summaryrefslogtreecommitdiff
path: root/modules/color
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-12-07 17:02:25 +0000
committerDries Buytaert <dries@buytaert.net>2006-12-07 17:02:25 +0000
commitf28aa5f3ecbd729b53894d7e091db0dab1368ddc (patch)
tree5068b84da3b5fb23fe8f27b19c253040ecd09a14 /modules/color
parent039453164e790bbebfb577732eb76c72caefb726 (diff)
downloadbrdo-f28aa5f3ecbd729b53894d7e091db0dab1368ddc.tar.gz
brdo-f28aa5f3ecbd729b53894d7e091db0dab1368ddc.tar.bz2
- Patch #92059 by Steven et al: added a memory check to garland/color.module.
Diffstat (limited to 'modules/color')
-rw-r--r--modules/color/color.module17
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);