mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.0' into 4.1
This commit is contained in:
commit
6d2665d687
@ -553,6 +553,7 @@ class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn a memory string, such as 512M into an actual number of bytes.
|
* 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"
|
* @param string $memString A memory limit string, such as "64M"
|
||||||
* @return float
|
* @return float
|
||||||
@ -562,7 +563,7 @@ class Convert
|
|||||||
// Remove non-unit characters from the size
|
// Remove non-unit characters from the size
|
||||||
$unit = preg_replace('/[^bkmgtpezy]/i', '', $memString);
|
$unit = preg_replace('/[^bkmgtpezy]/i', '', $memString);
|
||||||
// Remove non-numeric characters from the size
|
// Remove non-numeric characters from the size
|
||||||
$size = preg_replace('/[^0-9\.]/', '', $memString);
|
$size = preg_replace('/[^0-9\.\-]/', '', $memString);
|
||||||
|
|
||||||
if ($unit) {
|
if ($unit) {
|
||||||
// Find the position of the unit in the ordered string which is the power
|
// Find the position of the unit in the ordered string which is the power
|
||||||
|
@ -576,6 +576,7 @@ XML
|
|||||||
public function memString2BytesProvider()
|
public function memString2BytesProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
['-1', (float)-1],
|
||||||
['2048', (float)(2 * 1024)],
|
['2048', (float)(2 * 1024)],
|
||||||
['2k', (float)(2 * 1024)],
|
['2k', (float)(2 * 1024)],
|
||||||
['512M', (float)(512 * 1024 * 1024)],
|
['512M', (float)(512 * 1024 * 1024)],
|
||||||
|
Loading…
Reference in New Issue
Block a user