raise_memory() now uses get_real_size(), duplicate function return_bytes() removed.
Issue discussed in 2202 (http://moodle.org/bugs/bug.php?op=show&bugid=2202). Also seen as [email protected]/moodle--eduforge--1.3.3--patch-424
This commit is contained in:
+2
-30
@@ -3390,10 +3390,10 @@ function raise_memory_limit ($newlimit) {
|
||||
if ($cur == -1){
|
||||
return true; // unlimited mem!
|
||||
}
|
||||
$cur = return_bytes($cur);
|
||||
$cur = get_real_size($cur);
|
||||
}
|
||||
|
||||
$new = return_bytes($newlimit);
|
||||
$new = get_real_size($newlimit);
|
||||
if ($new > $cur) {
|
||||
ini_set('memory_limit', $newlimit);
|
||||
return true;
|
||||
@@ -3401,34 +3401,6 @@ function raise_memory_limit ($newlimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to transform strings like 5M or 128k into bytes.
|
||||
* Taken from PHP's documentation (see entry for ini_get())
|
||||
*
|
||||
* Return integer (in bytes)
|
||||
*
|
||||
* @param value string with the value
|
||||
*/
|
||||
function return_bytes($val) {
|
||||
$val = trim($val);
|
||||
if (empty($val)) {
|
||||
return '';
|
||||
}
|
||||
$last = $val{strlen($val)-1};
|
||||
switch($last) {
|
||||
case 'k':
|
||||
case 'K':
|
||||
return (int) $val * 1024;
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
return (int) $val * 1048576;
|
||||
break;
|
||||
default:
|
||||
return $val;
|
||||
}
|
||||
}
|
||||
|
||||
function unzip_show_status ($list,$removepath) {
|
||||
//This function shows the results of the unzip execution
|
||||
//depending of the value of the $CFG->zip, results will be
|
||||
|
||||
Reference in New Issue
Block a user