Merge pull request #8573 from wernerkrauss/fix-8570

Convert::memstring2bytes should preserve -1
This commit is contained in:
Robbie Averill 2018-11-06 11:02:23 +01:00 committed by GitHub
commit db425c76a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -553,6 +553,7 @@ class Convert
/**
* Turn a memory string, such as 512M into an actual number of bytes.
* Preserves integer values like "1024" or "-1"
*
* @param string $memString A memory limit string, such as "64M"
* @return float
@ -562,7 +563,7 @@ class Convert
// Remove non-unit characters from the size
$unit = preg_replace('/[^bkmgtpezy]/i', '', $memString);
// Remove non-numeric characters from the size
$size = preg_replace('/[^0-9\.]/', '', $memString);
$size = preg_replace('/[^0-9\.\-]/', '', $memString);
if ($unit) {
// Find the position of the unit in the ordered string which is the power

View File

@ -576,6 +576,7 @@ XML
public function memString2BytesProvider()
{
return [
['-1', (float)-1],
['2048', (float)(2 * 1024)],
['2k', (float)(2 * 1024)],
['512M', (float)(512 * 1024 * 1024)],