aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/plupload
diff options
context:
space:
mode:
authorEA117 <admin@ea117.com>2019-08-30 07:01:04 -0500
committerEA117 <admin@ea117.com>2019-08-30 07:01:04 -0500
commit5bd3b7ec378579dc84d2d838ba43d3a77f519159 (patch)
tree2b8090f69acdd5c4fec60f1356cf20665b501f83 /phpBB/phpbb/plupload
parentbf359d153dd0ff6cc9505cdd7bf8a7754b6a6073 (diff)
downloadforums-5bd3b7ec378579dc84d2d838ba43d3a77f519159.tar
forums-5bd3b7ec378579dc84d2d838ba43d3a77f519159.tar.gz
forums-5bd3b7ec378579dc84d2d838ba43d3a77f519159.tar.bz2
forums-5bd3b7ec378579dc84d2d838ba43d3a77f519159.tar.xz
forums-5bd3b7ec378579dc84d2d838ba43d3a77f519159.zip
[ticket/16141] plupload chunk_size when 'unlimited' is involved.
Change get_chunk_size() calculation to correctly calculate limits without letting a zero "unlimited" value always win. Also ensure get_chunk_size() can only return zero if all of the limits were in fact set to unlimited. PHPBB3-16141
Diffstat (limited to 'phpBB/phpbb/plupload')
-rw-r--r--phpBB/phpbb/plupload/plupload.php56
1 files changed, 23 insertions, 33 deletions
diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php
index 91b635b617..70070b9835 100644
--- a/phpBB/phpbb/plupload/plupload.php
+++ b/phpBB/phpbb/plupload/plupload.php
@@ -276,47 +276,37 @@ class plupload
}
/**
- * Checks various php.ini values to determine the maximum chunk
- * size a file should be split into for upload.
- *
- * The intention is to calculate a value which reflects whatever
- * the most restrictive limit is set to. And to then set the chunk
- * size to half that value, to ensure any required transfer overhead
- * and POST data remains well within the limit. Or, if all of the
- * limits are set to unlimited, the chunk size will also be unlimited.
- *
- * @return int
- */
+ * Checks various php.ini values to determine the maximum chunk
+ * size a file should be split into for upload.
+ *
+ * The intention is to calculate a value which reflects whatever
+ * the most restrictive limit is set to. And to then set the chunk
+ * size to half that value, to ensure any required transfer overhead
+ * and POST data remains well within the limit. Or, if all of the
+ * limits are set to unlimited, the chunk size will also be unlimited.
+ *
+ * @return int
+ *
+ * @access public
+ */
public function get_chunk_size()
{
$max = 0;
- // unlimited is -1 for memory_limit. 0 should be an invalid configuration.
- $limit_memory = $this->php_ini->getBytes('memory_limit');
-
- if ($limit_memory > 0)
- {
- $max = $limit_memory;
- }
-
- // For all remaining limits, 0 means "unlimited".
-
- $limit_upload = $this->php_ini->getBytes('upload_max_filesize');
+ $limits = [
+ $this->php_ini->getBytes('memory_limit'),
+ $this->php_ini->getBytes('upload_max_filesize'),
+ $this->php_ini->getBytes('post_max_size'),
+ ];
- if ($limit_upload > 0)
+ foreach ($limits as $limit_type)
{
- $max = min($limit_upload, ($max ? $max : $limit_upload));
- }
-
- $limit_post = $this->php_ini->getBytes('post_max_size');
-
- if ($limit_post > 0)
- {
- $max = min($limit_post, ($max ? $max : $limit_post));
+ if ($limit_type > 0)
+ {
+ $max = ($max !== 0) ? min($limit_type, $max) : $limit_type;
+ }
}
- // $config['max_filesize'] is not a limiter to chunk size.
-
return floor($max / 2);
}