Moodle

glossary id for random_glossary not recoded upon restore

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.5, 1.9
  • Fix Version/s: 1.8.6, 1.9.1
  • Component/s: Backup, Blocks, Glossary
  • Labels:
    None
  • Environment:
    All
  • Affected Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE

Description

The id of the glossary from which the random_glossary block takes its data is not recoded during restore.

  1. block_glossary_random_19_STABLE.patch
    23/Apr/08 9:36 AM
    0.9 kB
    Eloy Lafuente (stronk7)
  2. restore.patch
    05/Mar/08 6:45 AM
    4 kB
    Luke Hudson
  3. restorelib.php_18_STABLE.patch
    23/Apr/08 10:20 AM
    2 kB
    Eloy Lafuente (stronk7)

Activity

Hide
Luke Hudson added a comment -

It appears this is due to the block storing the source glossary id in its (base64-encoded) config column. The restore process doesn't know anything about this, and so cannot remap the old id to a new one.

Now, the restore process calls (if it exists) $block->after_restore(), so I tried to put a fix in there. However, at the time after_restore() is called, the restore process has not yet updated the course_module.instance field, so the block will only get '0' as the relevant glossary id.

So, I'm currently a little stuck. One solution would be to move the after_restore call to the end of the restore process, which means saving a list of restored blocks then iterating through those.

Any feedback or suggestions are welcomed; I'm keen to fix this as soon as I can.

Cheers,

  • Luke
Show
Luke Hudson added a comment - It appears this is due to the block storing the source glossary id in its (base64-encoded) config column. The restore process doesn't know anything about this, and so cannot remap the old id to a new one. Now, the restore process calls (if it exists) $block->after_restore(), so I tried to put a fix in there. However, at the time after_restore() is called, the restore process has not yet updated the course_module.instance field, so the block will only get '0' as the relevant glossary id. So, I'm currently a little stuck. One solution would be to move the after_restore call to the end of the restore process, which means saving a list of restored blocks then iterating through those. Any feedback or suggestions are welcomed; I'm keen to fix this as soon as I can. Cheers,
  • Luke
Hide
Luke Hudson added a comment -

Preliminary patch for Moodle 1.8 stable, to allow glossary_random block to relink to new glossary on restore

Show
Luke Hudson added a comment - Preliminary patch for Moodle 1.8 stable, to allow glossary_random block to relink to new glossary on restore
Hide
Luke Hudson added a comment -

I've attached my preliminary patch. It's not ideal, but it does solve the problem my client is having with their site. Comments/feedback/fixes welcomed
Cheers - Luke

Show
Luke Hudson added a comment - I've attached my preliminary patch. It's not ideal, but it does solve the problem my client is having with their site. Comments/feedback/fixes welcomed Cheers - Luke
Hide
Eloy Lafuente (stronk7) added a comment -

Hi Luke,

I've been looking your proposed patch and looks a bit complex IMO. Also.. it seems that only will work when restore happens in the SAME server where the original course is stored (because you look course_modules.

IMO it's really simpler if you, directly, ask to the backup_ids table about the glossary->id against the 'glossary' table.

I've added one patch (agains 19_STABLE) that seems to work properly (it's missing some output if the glossary cannot be found and so) IMO. More yet it works also if you restore the course in a different server.

And I think it can be backported to 18_STABLE easily, or am I missing anything?

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi Luke, I've been looking your proposed patch and looks a bit complex IMO. Also.. it seems that only will work when restore happens in the SAME server where the original course is stored (because you look course_modules. IMO it's really simpler if you, directly, ask to the backup_ids table about the glossary->id against the 'glossary' table. I've added one patch (agains 19_STABLE) that seems to work properly (it's missing some output if the glossary cannot be found and so) IMO. More yet it works also if you restore the course in a different server. And I think it can be backported to 18_STABLE easily, or am I missing anything? Ciao
Hide
Eloy Lafuente (stronk7) added a comment -

Hi again,

I've tested the patch against 18_STABLE and it seems to be another bug in the restoring of blocks, not able to properly generate contexts (!!!) because of missing $instance->id or so.

So I've backported from 19_STABLE the minimum required to have 1.8 restore of blocks working properly.

So here it's another patch, for 18_STABLE, that:

1) Fixes problems in restore of blocks.
2) At the same time, enable the glossary_random patch to work under 18_STABLE

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi again, I've tested the patch against 18_STABLE and it seems to be another bug in the restoring of blocks, not able to properly generate contexts (!!!) because of missing $instance->id or so. So I've backported from 19_STABLE the minimum required to have 1.8 restore of blocks working properly. So here it's another patch, for 18_STABLE, that: 1) Fixes problems in restore of blocks. 2) At the same time, enable the glossary_random patch to work under 18_STABLE Ciao
Hide
Eloy Lafuente (stronk7) added a comment -

Adding Petr here.... he did changes in restore of blocks for 19_STABLE...

Hi Petr,

the basic proposal here is to:

1) Apply restorelib.php_18_STABLE.patch to 1.8. I've backported it from your 1.9 code (only the minimum needed to allow 1.9 to work, basically the lack og $instance->id was causing a lot of stuff to fail (contexts creation, after_restore()...).

2) Apply block_glossary_random_19_STABLE.patch from 1.8 (if previous point is ok), 1.9 and HEAD.

I've performed some tests both with 1) and 2) and seem to be working ok. For your consideration. I think the change in 1.8 stable is safe and will save some problems.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Adding Petr here.... he did changes in restore of blocks for 19_STABLE... Hi Petr, the basic proposal here is to: 1) Apply restorelib.php_18_STABLE.patch to 1.8. I've backported it from your 1.9 code (only the minimum needed to allow 1.9 to work, basically the lack og $instance->id was causing a lot of stuff to fail (contexts creation, after_restore()...). 2) Apply block_glossary_random_19_STABLE.patch from 1.8 (if previous point is ok), 1.9 and HEAD. I've performed some tests both with 1) and 2) and seem to be working ok. For your consideration. I think the change in 1.8 stable is safe and will save some problems. Ciao
Hide
Petr Škoda (skodak) added a comment -

+1 for this idea, going to review the code on Saturday

Show
Petr Škoda (skodak) added a comment - +1 for this idea, going to review the code on Saturday
Hide
Petr Škoda (skodak) added a comment -

confirming my +1 for commit in 1.8 and above, thanks!

Show
Petr Škoda (skodak) added a comment - confirming my +1 for commit in 1.8 and above, thanks!
Hide
Eloy Lafuente (stronk7) added a comment -

Done, both patches have been applied as commented.

Resolving as fixed...thanks and ciao

Show
Eloy Lafuente (stronk7) added a comment - Done, both patches have been applied as commented. Resolving as fixed...thanks and ciao
Hide
Luke Hudson added a comment -

Great! I see your point Eloy about the course_modules table. I'll merge this back into my branch. Cheers.

Show
Luke Hudson added a comment - Great! I see your point Eloy about the course_modules table. I'll merge this back into my branch. Cheers.
Hide
Petr Škoda (skodak) added a comment -

reviewed, thanks!

Show
Petr Škoda (skodak) added a comment - reviewed, thanks!

Dates

  • Created:
    Updated:
    Resolved: