From 8a91d7fcf3a5cacfbf7e37ffc9e8fe8fe6620c35 Mon Sep 17 00:00:00 2001 From: skodak Date: Wed, 5 Jul 2006 08:38:34 +0000 Subject: [PATCH] changed memory limit test in healthcenter; merged from MOODLE_16_STABLE --- admin/health.php | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/admin/health.php b/admin/health.php index b2211d3963..4955b69a09 100644 --- a/admin/health.php +++ b/admin/health.php @@ -356,24 +356,41 @@ class problem_000008 extends problem_base { return 'PHP: memory_limit cannot be controlled by Moodle'; } function exists() { - $memlimit = @ini_get('memory_limit'); - if(empty($memlimit)) { + $oldmemlimit = @ini_get('memory_limit'); + if(empty($oldmemlimit)) { // PHP not compiled with memory limits, this means that it's - // probably limited to 8M so we have a problem... - return true; + // probably limited to 8M or in case of Windows not at all. + // We can ignore it for now - there is not much to test anyway + // TODO: add manual test that fills memory?? + return false; + } + $oldmemlimit = get_real_size($oldmemlimit); + //now lets change the memory limit to something unique below 128M==134217728 + @ini_set('memory_limit', 134217720); + $testmemlimit = get_real_size(@ini_get('memory_limit')); + //verify the change had any effect at all + if ($oldmemlimit == $testmemlimit) { + //memory limit can not be changed - is it big enough then? + if ($oldmemlimit < get_real_size('128M')) { + return true; + } else { + return false; + } } - // Otherwise, raise_memory_limit in setup.php will do the trick + @ini_set('memory_limit', $oldmemlimit); return false; } function severity() { - return SEVERITY_ANNOYANCE; + return SEVERITY_NOTICE; } function description() { - return 'The settings for PHP on your server do not allow a script to request more memory during its execution. This means that most likely there is a hard limit of 8MB for each script. It is possible that certain operations within Moodle will require more than this amount in order to complete successfully, especially if there are lots of data to be processed. Therefore, it is recommended that you contact your server administrator to address this issue.'; + return 'The settings for PHP on your server do not allow a script to request more memory during its execution. '. + 'This means that there is a hard limit of '.@ini_get('memory_limit').' for each script. '. + 'It is possible that certain operations within Moodle will require more than this amount in order '. + 'to complete successfully, especially if there are lots of data to be processed.'; } function solution() { - global $CFG; - return 'We need a good solution here. Enabling memory limit control means recompiling PHP... maybe this should be SEVERITY_NOTICE instead of SEVERITY_ANNOYANCE?'; + return 'It is recommended that you contact your web server administrator to address this issue.'; } } -- 2.39.5