aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/plupload/plupload.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/plupload/plupload.php')
-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);
}