Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-26616

On migrating to 2.0+ files create two rows in mdl_files with the same sortorder, breaking the links

XMLWordPrintable

    • MySQL
    • MOODLE_20_STABLE
    • MOODLE_20_STABLE
    • Moderate

      The symptom is after upgrading, when some links to files were clicked you get a message like "Sorry, the requested file could not be found", after editing the resource and saving the problem was gone.

      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 (according to documentation): 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;

      Hope it helps you fixing it.

            skodak Petr Skoda
            villalon Jorge Villalon
            David Mudrák (@mudrd8mz) David Mudrák (@mudrd8mz)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.