From bc42e979895e999bccd8e32f20e42d401a6ed93b Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Tue, 6 Aug 2013 13:46:31 +0800 Subject: [PATCH] MDL-40086 file: Correct ordering of subdirectories Thanks to Mohamed Alsharaf for the proposed solution. --- lib/filestorage/file_storage.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/filestorage/file_storage.php b/lib/filestorage/file_storage.php index 31fd1fbf93c2f..581ab4c5dbce7 100644 --- a/lib/filestorage/file_storage.php +++ b/lib/filestorage/file_storage.php @@ -647,8 +647,10 @@ public function get_area_tree($contextid, $component, $filearea, $itemid) { protected function sort_area_tree($tree) { foreach ($tree as $key => &$value) { if ($key == 'subdirs') { - $value = $this->sort_area_tree($value); collatorlib::ksort($value, collatorlib::SORT_NATURAL); + foreach ($value as $subdirname => &$subtree) { + $subtree = $this->sort_area_tree($subtree); + } } else if ($key == 'files') { collatorlib::ksort($value, collatorlib::SORT_NATURAL); }