1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-24 01:20:40 +01:00

[ticket/16141] plupload chunk_size incorrect 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
This commit is contained in:
EA117 2019-08-26 21:07:01 -05:00
parent 9c15594fe4
commit 4cdfb3f4ed

View File

@ -283,15 +283,51 @@ class plupload
*/
public function get_chunk_size()
{
$max = min(
$this->php_ini->getBytes('upload_max_filesize'),
$this->php_ini->getBytes('post_max_size'),
max(1, $this->php_ini->getBytes('memory_limit')),
$this->config['max_filesize']
);
$max = 0;
$limit = $this->php_ini->getBytes('memory_limit');
// unlimited is -1 for memory_limit. 0 would be an invalid configuration.
if ($limit > 0)
{
$max = $limit;
}
// For all remaining limits, 0 means "unlimited".
// For each limit, if there is a non-unlimited value to
// apply, apply the limit if it's less than whatever non-
// unlimited max value is currently set. Also, apply the
// limit if the current max value is otherwise unlimited.
$limit = $this->php_ini->getBytes('upload_max_filesize');
if ($limit > 0)
{
$max = min($limit, max($max, $limit));
}
$limit = $this->php_ini->getBytes('post_max_size');
if ($limit > 0)
{
$max = min($limit, max($max, $limit));
}
$limit = $this->config['max_filesize'];
if ($limit > 0)
{
$max = min($limit, max($max, $limit));
}
// Only if every limit was 0/unlimited will we still
// have a zero value in $max at this point.
// Use half of the maximum possible to leave plenty of
// room for other POST data and be well under limits.
// Use half of the maximum possible to leave plenty of room for other
// POST data.
return floor($max / 2);
}