History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: CHD-2012
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Assignee: Scott Luther
Reporter: Dan Hildebrandt [WGM]
Votes: 0
Watchers: 0
Operations

Clone this issue
If you were logged in you would be able to see more operations.
Cerberus Helpdesk

[Install] Update memory_limit check to look at units as well as numerical value

Created: 16/Aug/10 12:09 PM   Updated: 22/Aug/10 12:47 PM
Fix Version/s: 5.1-rc1

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown


 Description   
servercheck.php intvals the memory_limit variable for comparison, so it doesn't report the correct answer when looking at memory_limits specified in GB (at least under 16GB, that is).

 All   Comments   Work Log   Change History      Sort Order:
Comment by Scott Luther [19/Aug/10 01:43 PM]
function get_bytes($mem_limit) {
    if(is_numeric($mem_limit)) {
        return $mem_limit;
    } else {
        $numeric_value = substr($mem_limit, 0, strlen($mem_limit) - 1);
        $unit_value = strtolower(substr($mem_limit, strlen($mem_limit) - 1));
        
        switch($unit_value) {
            case 'g':
                return $numeric_value * 1024 * 1024 * 1024;
                break;
            default:
            case 'm':
                return $numeric_value * 1024 * 1024;
                break;
            case 'k':
                return $numeric_value * 1024;
                break;
        }
    }
}

Example usage:

print get_bytes(ini_get("memory_limit"));

Comment by Jeff Standen [WGM] [22/Aug/10 12:47 PM]
Fixed in 5.1 (Builds 2010082201+)