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

Check if a capability exists before assigning during the restore process

    XMLWordPrintable

    Details

    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE, MOODLE_37_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-65326-master

      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 Matt Porritt
            Integrator:
            Jake Dallimore Jake Dallimore
            Tester:
            Anna Carissa Sadia Anna Carissa Sadia
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            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