samdark/realpath_cache_tuner

possible error in the script?

Closed this issue · 3 comments

I tried to run script and got:

A non well formed numeric value encountered

Line

$last = strtolower($value[strlen($value) - 1]);
gets last symbol and transforms it to lowercase, but whole string in such case is not transformed and contain that symbol!

And next lines:

switch($last) {
case 'g':
$value *= 1024;
case 'm':
$value *= 1024;
case 'k':
$value *= 1024;
}

what is the difference? any case inside switch do exactly same task.

UPD oops, I missed there are no break statement. ok, anyway $value is still seems incorrect for calculations.

UPD2 I think next code after line #12 may fix that issue:

if ($last) $value = substr($value, 0, strlen($value) - 1);

What do you have in $value when it errors?

4096K

-- string returned by ini_get('realpath_cache_size')

Fixed with 1d84ab8. Thanks for reporting!