improve memory check output

Makes use of the adjusted php_to_bytes() method which correctly returns
-1 for unlimited RAM and uses human readable sizes for output.
This commit is contained in:
Andreas Gohr 2019-04-24 14:21:36 +02:00
parent a81f3d99fc
commit c6e971dde7
1 changed files with 6 additions and 10 deletions

View File

@ -132,23 +132,19 @@ function check(){
msg('Your PHP version is too old',-1);
}
}
$limit = ini_get('memory_limit');
if($limit == -1) {
$mem = -1; // unlimited
} else {
$mem = (int) php_to_byte($limit);
}
$mem = (int) php_to_byte(ini_get('memory_limit'));
if($mem){
if($mem == -1) {
msg('PHP memory is unlimited', 1);
} else if($mem < 16777216){
msg('PHP is limited to less than 16MB RAM ('.$mem.' bytes). Increase memory_limit in php.ini',-1);
msg('PHP is limited to less than 16MB RAM ('.filesize_h($mem).'). Increase memory_limit in php.ini',-1);
} else if($mem < 20971520){
msg('PHP is limited to less than 20MB RAM ('.$mem.' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini',-1);
msg('PHP is limited to less than 20MB RAM ('.filesize_h($mem).'), you might encounter problems with bigger pages. Increase memory_limit in php.ini',-1);
} else if($mem < 33554432){
msg('PHP is limited to less than 32MB RAM ('.$mem.' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini',0);
msg('PHP is limited to less than 32MB RAM ('.filesize_h($mem).'), but that should be enough in most cases. If not, increase memory_limit in php.ini',0);
} else {
msg('More than 32MB RAM ('.$mem.' bytes) available.',1);
msg('More than 32MB RAM ('.filesize_h($mem).') available.',1);
}
}