File Links broken after upgrade

FOUND THE BUG!

by Jorge Villalon -
Number of replies: 0

Hi guys.

I found the bug for the links broken after upgrade. The problem is in the resource lib, in the function resource_get_coursemodule_info in which the module gets all the files for a context and if there are more than one, it pops the first one in the list.

The problem is that when you migrate to 2.0+ all files create two resources: The file itself and the folder where it belongs, and the sortorder for both is exactly the same: 0. So when mysql returns the file first, it works, and when it returns the other way around it doesn't (pretty hard to find).

I fixed it by updating the sortorder to 1 for all rows in mdl_files that had component 'mod_resource' and did not have a filename equal to '.' (folder). I also deleted the course cached info. In sql:

update mdl_files set sortorder=1 where component='mod_resource' and filename <> '.' and sortorder = 0;

update mdl_course set modinfo = NULL;

It will be fixed for 2.0.3, but you can use my workaround for now.

http://tracker.moodle.org/browse/MDL-26616

Average of ratings: Useful (3)