From 14e497c06ea851499da5cd030d5ab6bfe55eeedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Sat, 15 Sep 2012 11:13:04 +0200 Subject: [PATCH] MDL-35454 ignore invalid $custombytes in get_max_upload_sizes() This fixes installation and phpunit init regression. --- lib/moodlelib.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 93687a16d7e..618f890d823 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5824,16 +5824,19 @@ function get_max_upload_sizes($sitebytes = 0, $coursebytes = 0, $modulebytes = 0 return array(); } + $filesize = array(); $filesize[intval($maxsize)] = display_size($maxsize); $sizelist = array(10240, 51200, 102400, 512000, 1048576, 2097152, 5242880, 10485760, 20971520, 52428800, 104857600); - // If custombytes is given then add it to the list. - if (!is_null($custombytes)) { - if (is_number($custombytes)) { - $custombytes = array((int)$custombytes); + // If custombytes is given and is valid then add it to the list. + if (is_number($custombytes) and $custombytes > 0) { + $custombytes = (int)$custombytes; + if (!in_array($custombytes, $sizelist)) { + $sizelist[] = $custombytes; } + } else if (is_array($custombytes)) { $sizelist = array_unique(array_merge($sizelist, $custombytes)); }