mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[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
This commit is contained in:
parent
bf359d153d
commit
5bd3b7ec37
1 changed files with 23 additions and 33 deletions
|
@ -286,37 +286,27 @@ class plupload
|
||||||
* limits are set to unlimited, the chunk size will also be unlimited.
|
* limits are set to unlimited, the chunk size will also be unlimited.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function get_chunk_size()
|
public function get_chunk_size()
|
||||||
{
|
{
|
||||||
$max = 0;
|
$max = 0;
|
||||||
|
|
||||||
// unlimited is -1 for memory_limit. 0 should be an invalid configuration.
|
$limits = [
|
||||||
$limit_memory = $this->php_ini->getBytes('memory_limit');
|
$this->php_ini->getBytes('memory_limit'),
|
||||||
|
$this->php_ini->getBytes('upload_max_filesize'),
|
||||||
|
$this->php_ini->getBytes('post_max_size'),
|
||||||
|
];
|
||||||
|
|
||||||
if ($limit_memory > 0)
|
foreach ($limits as $limit_type)
|
||||||
{
|
{
|
||||||
$max = $limit_memory;
|
if ($limit_type > 0)
|
||||||
}
|
|
||||||
|
|
||||||
// For all remaining limits, 0 means "unlimited".
|
|
||||||
|
|
||||||
$limit_upload = $this->php_ini->getBytes('upload_max_filesize');
|
|
||||||
|
|
||||||
if ($limit_upload > 0)
|
|
||||||
{
|
{
|
||||||
$max = min($limit_upload, ($max ? $max : $limit_upload));
|
$max = ($max !== 0) ? min($limit_type, $max) : $limit_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
$limit_post = $this->php_ini->getBytes('post_max_size');
|
|
||||||
|
|
||||||
if ($limit_post > 0)
|
|
||||||
{
|
|
||||||
$max = min($limit_post, ($max ? $max : $limit_post));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// $config['max_filesize'] is not a limiter to chunk size.
|
|
||||||
|
|
||||||
return floor($max / 2);
|
return floor($max / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue