Moodle

Backup/restore process does not keep the role overrides in the activities

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9.1
  • Fix Version/s: 1.9.5
  • Component/s: Backup
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

Hello Eloy,

One of our clients relies quite heavily on the backup restore process to create multiple runs of a single course. While testing their setup we have found out that the role overrides do not seem to be kept for activity modules.

For example: I have created a forum where I want students to rate eachother using a scale. I can only get this working by overriding the permissions (the legacy student role cannot rate posts) for that forum. When I then backup the course and restore it, it has lost the role overrides. Is this because I haven't backed up the role assignments?

Is this a known problem (I couldn't find it in the tracker) and is this something that could/will be fixed in the near future? I can imagine it might be hard to fix (you do not know the role definitions in the destination installation), but it should be thought about because more and more settings about activities are moved into the capabilities system...

Kind regards,

Hans

Issue Links

Activity

Hide
Konstantin Etkine added a comment -

I just discovered it is also happening with blocks. See tracker issue 16518

Why this issue is marked "minor?" It is major.

How could such a large problem go unnoticed?

No testing, I guess.

And How could such a major probelm go without fixing so long without even a little comment from developer? ??!

Show
Konstantin Etkine added a comment - I just discovered it is also happening with blocks. See tracker issue 16518 Why this issue is marked "minor?" It is major. How could such a large problem go unnoticed? No testing, I guess. And How could such a major probelm go without fixing so long without even a little comment from developer? ??!
Hide
Clinton Graham added a comment -

Even though the role overrides are backed up in the XML, unless the roles themselves are backed up as well, the overrides will not be restored. The first if statement in restore_write_roleoverrides() returns null if the role is not found in the XML.

Currently it seems a role is only written to the XML if a user is assigned to the role within the course. It seems to me that a role should also be written if any override exists for it.

Show
Clinton Graham added a comment - Even though the role overrides are backed up in the XML, unless the roles themselves are backed up as well, the overrides will not be restored. The first if statement in restore_write_roleoverrides() returns null if the role is not found in the XML. Currently it seems a role is only written to the XML if a user is assigned to the role within the course. It seems to me that a role should also be written if any override exists for it.
Hide
Clinton Graham added a comment -

My suggestion above can be implemented with:

Index: backup/backuplib.php
===================================================================
— backup/backuplib.php (revision 59)
+++ backup/backuplib.php (working copy)
@@ -2811,6 +2811,11 @@

// foreach context, call get_roles_on_exact_context insert into array
foreach ($contexts as $context) {
+ if ($proles = get_roles_with_override_on_context($context)) {
+ foreach ($proles as $prole) { + $roles[$prole->id] = $prole; + }
+ }
if ($proles = get_roles_on_exact_context($context)) {
foreach ($proles as $prole) {
$roles[$prole->id] = $prole;

Show
Clinton Graham added a comment - My suggestion above can be implemented with: Index: backup/backuplib.php =================================================================== — backup/backuplib.php (revision 59) +++ backup/backuplib.php (working copy) @@ -2811,6 +2811,11 @@ // foreach context, call get_roles_on_exact_context insert into array foreach ($contexts as $context) { + if ($proles = get_roles_with_override_on_context($context)) { + foreach ($proles as $prole) { + $roles[$prole->id] = $prole; + } + } if ($proles = get_roles_on_exact_context($context)) { foreach ($proles as $prole) { $roles[$prole->id] = $prole;
Hide
Eloy Lafuente (stronk7) added a comment -

Well spotted Clinton!

Hans, can you confirm that those overrides in module belongs to one student whose role has been assigned at category level?

And thanks for ping-ing this with your comment, Clinton. It was lost in my mare-magnum of pending bugs!

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Well spotted Clinton! Hans, can you confirm that those overrides in module belongs to one student whose role has been assigned at category level? And thanks for ping-ing this with your comment, Clinton. It was lost in my mare-magnum of pending bugs! Ciao
Hide
Hans de Zwart added a comment -

Hello Eloy,

The course which gave the problems indeed did not have any registered students, they were all assigned at the category level. The role override was for the legacy student role in a particular forum. Hope this helps to confirm the solution.

Kind regards,

Hans

Show
Hans de Zwart added a comment - Hello Eloy, The course which gave the problems indeed did not have any registered students, they were all assigned at the category level. The role override was for the legacy student role in a particular forum. Hope this helps to confirm the solution. Kind regards, Hans
Hide
Eloy Lafuente (stronk7) added a comment -

Suggested change applied both to 19_STABLE and HEAD. Tests OK.

Thanks Clinton!

Resolving this as fixed. Ciao

Show
Eloy Lafuente (stronk7) added a comment - Suggested change applied both to 19_STABLE and HEAD. Tests OK. Thanks Clinton! Resolving this as fixed. Ciao
Hide
Petr Škoda (skodak) added a comment -

thanks everybody

Show
Petr Škoda (skodak) added a comment - thanks everybody

Dates

  • Created:
    Updated:
    Resolved: