diff --git a/mod/resource/lib.php b/mod/resource/lib.php index e357e462719fb..341e588fc406a 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -257,7 +257,7 @@ function resource_get_coursemodule_info($coursemodule) { $fs = get_file_storage(); $files = $fs->get_area_files($context->id, 'mod_resource', 'content', 0, 'sortorder DESC, id ASC', false); // TODO: this is not very efficient!! if (count($files) >= 1) { - $mainfile = array_pop($files); + $mainfile = reset($files); $info->icon = file_extension_icon($mainfile->get_filename()); $resource->mainfile = $mainfile->get_filename(); }