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

Check if a capability exists before assigning during the restore process

    XMLWordPrintable

    Details

      Description

      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."

        Attachments

          Activity

            People

            Assignee:
            dmitriim Dmitrii Metelkin
            Reporter:
            dmitriim Dmitrii Metelkin
            Peer reviewer:
            Matt Porritt
            Integrator:
            Jake Dallimore
            Tester:
            Anna Carissa Sadia
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              8/Jul/19

                Time Tracking

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