summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-08-22 12:18:36 +0200
committerAndrey Andreev <narf@devilix.net>2016-08-22 12:18:36 +0200
commit549a601bac3b1467168e0bb7b5642ba7fc59c35e (patch)
treecf93e74fcd642f213514549329bc8168b5fe1320
parent1927709235ed11f51b700abcb390b660e2762053 (diff)
Fix CI_Upload errors on PHP 7.1
-rw-r--r--system/libraries/Upload.php23
-rw-r--r--user_guide_src/source/changelog.rst1
2 files changed, 21 insertions, 3 deletions
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index a8cf75264..23fd02ead 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1083,10 +1083,27 @@ class CI_Upload {
return FALSE;
}
- if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')))
+ if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')) > 0)
{
- $memory_limit *= 1024 * 1024;
- $memory_limit = (int) ceil(filesize($file) + $memory_limit);
+ $memory_limit = str_split($memory_limit, strspn($memory_limit, '1234567890'));
+ if ( ! empty($memory_limit[1]))
+ {
+ switch ($memory_limit[1][0])
+ {
+ case 'g':
+ case 'G':
+ $memory_limit[0] *= 1024 * 1024 * 1024;
+ break;
+ case 'm':
+ case 'M':
+ $memory_limit[0] *= 1024 * 1024;
+ break;
+ default:
+ break;
+ }
+ }
+
+ $memory_limit = (int) ceil(filesize($file) + $memory_limit[0]);
ini_set('memory_limit', $memory_limit); // When an integer is used, the value is measured in bytes. - PHP.net
}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 4870cb1a8..97b4d254d 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -21,6 +21,7 @@ Bug fixes for 3.1.1
- Fixed a bug (#4754) - :doc:`Unit Testing Library <libraries/unit_testing>` method ``result()`` didn't translate ``res_datatype``.
- Fixed a bug (#4759) - :doc:`Form Validation <libraries/form_validation>`, :doc:`Trackback <libraries/trackback>` and `XML-RPC <libraries/xmlrpc>` libraries treated URI schemes in a case-sensitive manner.
- Fixed a bug (#4762) - :doc:`Cache Library <libraries/caching>` 'file' driver method ``get_metadata()`` checked TTL time against ``mtime`` instead of the cache item's creation time.
+- Fixed a bug where :doc:`File Uploading Library <libraries/file_uploading>` generated error messages on PHP 7.1.
Version 3.1.0
=============