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

Check if a capability exists before assigning during the restore process

XMLWordPrintable

    • MOODLE_35_STABLE
    • MOODLE_36_STABLE, MOODLE_37_STABLE
    • MDL-65326-master
    • Hide
      1. Create a course.
      2. Go to Course administration > Users > Permissions
      3. Pick one of the roles in Advanced role override
      4. Override mod/lesson:addinstance permission
      5. Backup the course and download the file.
      6. Uninstall mod_lesson and delete mod/lesson folder completely from the code base to make sure that the activity won't be reinstalled.
      7. Restore as a new course from the file you got on step 5
      8. Make sure you can successfully restore the backup file.
      Show
      Create a course. Go to Course administration > Users > Permissions Pick one of the roles in Advanced role override Override mod/lesson:addinstance permission Backup the course and download the file. Uninstall mod_lesson and delete mod/lesson folder completely from the code base to make sure that the activity won't be reinstalled. Restore as a new course from the file you got on step 5 Make sure you can successfully restore the backup file.

      We got a situation when some custom code broke backup files and particular capabilities in /course/roles.xml

      Looking at the code it seems like there is TODO saying "it seems that assign_capability() doesn't check for valid capabilities at all ???"  

      If we look at the assign_capability method, it currently checks for that, and throws and exception.

      This breaks restore process. I think, it's better to log a warning instead and let the backup process to complete. 

      Original Replication instructions:

      1. Create a course.
      2. Go to Course administration > Users > Permissions
      3. Pick one of the roles in Advanced role override
      4. Override mod/lesson:addinstance permission
      5. Backup the course and download the file.
      6. Uninstall mod_lesson and delete mod/lesson folder completely from the code base to make sure that the activity won't be reinstalled.
      7. Restore as a new course from the file you got on step 5
      8. Notice you get "Coding error detected, it must be fixed by a programmer: Capability 'mod/lesson:addinstance' was not found! This has to be fixed in code."

            dmitriim Dmitrii Metelkin
            dmitriim Dmitrii Metelkin
            Matt Porritt Matt Porritt
            Jake Dallimore Jake Dallimore
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours
                4h

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