Commit d08421f2 authored by Manfred Kutas's avatar Manfred Kutas

ZP-1376 Return false in IsRequestMemoryLimitReached if memory_limit set

to -1.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 1ecfcba2
......@@ -198,9 +198,17 @@ class Request {
}
// get & convert configured memory limit
(int)preg_replace_callback('/(\-?\d+)(.?)/', function ($m) {
self::$memoryLimit = $m[1] * pow(1024, strpos('BKMG', $m[2])) * self::MAXMEMORYUSAGE;
}, strtoupper(ini_get('memory_limit')));
$memoryLimit = ini_get('memory_limit');
if ($memoryLimit == -1) {
self::$memoryLimit = false;
}
else {
(int)preg_replace_callback('/(\-?\d+)(.?)/',
function ($m) {
self::$memoryLimit = $m[1] * pow(1024, strpos('BKMG', $m[2])) * self::MAXMEMORYUSAGE;
},
strtoupper($memoryLimit));
}
}
/**
......@@ -700,6 +708,9 @@ class Request {
* @return boolean
*/
static public function IsRequestMemoryLimitReached() {
if (self::$memoryLimit === false) {
return false;
}
return memory_get_peak_usage(true) >= self::$memoryLimit;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment