Commit 3ac8c74b authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #670 in ZP/z-push from...

Merge pull request #670 in ZP/z-push from bugfix/ZP-1376-out-of-memory-check-when-memory_limit-1 to develop

* commit 'd08421f2':
  ZP-1376 Return false in IsRequestMemoryLimitReached if memory_limit set to -1.
parents c7a0e097 d08421f2
......@@ -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));
}
}
/**
......@@ -709,6 +717,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