public static getMemoryLimitValue ( ) : integer | boolean | ||
return | integer | boolean | memory limit in megabytes, or false if there is no limit |
public static function getMemoryLimitValue()
{
if (($memory = ini_get('memory_limit')) > 0) {
// handle shorthand byte options (case-insensitive)
$shorthandByteOption = substr($memory, -1);
switch ($shorthandByteOption) {
case 'G':
case 'g':
return substr($memory, 0, -1) * 1024;
case 'M':
case 'm':
return substr($memory, 0, -1);
case 'K':
case 'k':
return substr($memory, 0, -1) / 1024;
}
return $memory / 1048576;
}
// no memory limit
return false;
}
public function execute() { $label = $this->translator->translate('Installation_SystemCheckMemoryLimit'); SettingsServer::raiseMemoryLimitIfNecessary(); $memoryLimit = SettingsServer::getMemoryLimitValue(); $comment = $memoryLimit . 'M'; if ($memoryLimit >= $this->minimumMemoryLimit) { $status = DiagnosticResult::STATUS_OK; } else { $status = DiagnosticResult::STATUS_WARNING; $comment .= sprintf('<br />%s<br />%s', $this->translator->translate('Installation_SystemCheckMemoryLimitHelp'), $this->translator->translate('Installation_RestartWebServer')); } return array(DiagnosticResult::singleResult($label, $status, $comment)); }