Issue Details (XML | Word | Printable)

Key: MDL-10993
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Eloy Lafuente (stronk7)
Reporter: John Isner
Votes: 18
Watchers: 22
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Restore creates duplicate activity/resource icons with no text

Created: 25/Aug/07 02:40 PM   Updated: 13/Feb/09 05:33 AM
Return to search
Component/s: Backup
Affects Version/s: 1.8.2, 1.8.3, 1.8.4
Fix Version/s: None

File Attachments: None
Image Attachments:

1. duplicate_icons.png
(13 kB)

2. indexes_appear_to_be_equal.jpg
(88 kB)
Issue Links:
Dependency
 
Duplicate
 

Participants: Ann Adamcik, Claudio Gasparini, David Mudrak, Eloy Lafuente (stronk7), Janet Hayes, John Isner, Kenneth Newquist, Michael Spall, Morten Brydensholt, Petr Skoda, Richard Platts, Robert Duncan, Susana Leitão and Tiffany DeJager
Security Level: None
Affected Branches: MOODLE_18_STABLE


 Description  « Hide
I reported this problem in MDL-10815, thinking it was related to SCORM. Today, another user (Robert Duncan) reported the same problem in http://moodle.org/mod/forum/discuss.php?d=78587. In both cases, we are restoring a course into a new empty course. Duplicate resource/activity icons are created with no text (see screenshot). In both cases, no third-party modules were involved. In my case, the restore was from another course backed up on the same 1.8.2 site. In my case, there was an error at the end of the restore "An error has occurred and the restore could not be completed!" but the new course was left in the corrupted state shown. I'm not sure if Robert Duncan received this message (it came at the very end of the restore log and would be easy to ignore).


 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Robert Duncan added a comment - 28/Aug/07 01:04 AM
I (Rob Duncan) did not get the error message. Instead, when I imported an old course into a newly created one, I got "Import complete! Continue to your course" When I continue to the course, I have the problem described above.

Richard Platts added a comment - 02/Sep/07 12:14 AM
I've experience a similar issue using 1.8.2 after importing activities from another course to duplicate identical content.

By turning off AJAX I can delete the activities from the course, but they appear in the Journal Overview still. Though there is no resource id for the orphan activities.

Deleted Resources DO NOT appear in the summary list, nor Quizzes, but forums DO APPEAR as blank "ghosts" in the summary.

When my nightly backup was run, it returned ERROR in the email alerting me to completion. When I ran cron after deleting the blank activities, it seemed to run without returning an error.

Hope this helps.


Richard Platts added a comment - 02/Sep/07 05:02 AM
The above issue seems to have resolved itself after a few hours. I didn't do anything different. The additional activities appear to be gone now.

Robert Duncan added a comment - 07/Sep/07 08:26 PM
One more thing I've noticed. The two classes that I duplicated that created this issue are not backing up properly. In my backup log, it says "Error."

Morten Brydensholt added a comment - 15/Sep/07 09:18 PM
When I restore or import courses the new courses has empty activities with no links.

I have checked, optimized and repaired the database with no luck.

Fiddling around the database I found this warning in a lot of the tables:

"The following indexes appear to be equal and one of them should be removed: PRIMARY, id".

So, should I simply remove one of the indexes? Which one?

Turning on error logs told me, that there was a duplicate entry in 'mdl_backup_ids'. How do I delete this?

Besides trying to browse 'mdl_backup_ids' and 'mdl_backup_files' I get the message "Table seems to be empty".

Is my database just corrupted?

Is it safe to install a fresh version of Moodle and restore everything from the backups?


Janet Hayes added a comment - 04/Dec/07 08:01 AM
I get an error message with many of my tables that says...

The following indexes appear to be equal and one of them should be removed: PRIMARY, id

what should I do about this? ..best..janet

btw... I tried to use your screenshot attachment device, but it didn't work... (mac OSX 10.4.x/Safari)


Ann Adamcik added a comment - 17/Jan/08 03:00 AM
I've been able to reproduce this on both 1.8.4 and 1.9. Here are the steps I used to reproduce it on demo.moodle.org:

Log in as admin, create a blank course, and assign a teacher.
Log in as a teacher, enter the course, and import activities from another course.
Repeat the import process with the same course.

The result is a bunch of icons with no text. Clicking on these icons gives the message "Course Module ID was incorrect".

Note that in many cases on our production 1.8.4 environment, the orphaned icons do appear after the first import. We also have faculty that have run into this when restoring a backup into a new course.


Ann Adamcik added a comment - 25/Apr/08 04:08 AM
Our faculty continue to run into this issue. Here are some additional details -

Once there are 'orphaned' icons in the course, they cannot be removed if AJAX is enabled. If the user turns off AJAX, the blank activities/resources can be removed. However, removing them does not trigger rebuild_course_cache, so these empty items still show up in certain places. For instance, if you remove non-existent quizzes, clicking on 'Quizzes' in the course Activities block will bring up a table with blank lines for the removed quizzes. Also, the course backup page will show check boxes for any removed items. These empty items can cause a subsequent course backup to fail.

So, I still haven't figured out why import/restore sometimes creates these duplicate/empty icons, but when it does, there is a 2-step workaround to get rid of them -

1. Turn off AJAX and delete the items.
2. Toggle the visibility of any section to trigger rebuild_course_cache.


Eloy Lafuente (stronk7) added a comment - 29/Apr/08 07:47 AM
Hi I guess MDL-14326 will help resolve this.

It's strange that it's happening in successfully restored courses because rebuild_course_cache() is executed as one of the final steps of restore. Uhm. I'll try to comment here about how the other bug evolves.

Ciao


David Mudrak added a comment - 02/May/08 04:35 AM
Hi

the fix of MDL-14326 actually works but it just removes the empty icons and leaves the target course empty after the failed import. I have followed Ann's step-by-steps and got some PHP Notices. I am going to check and will let you know.

?au


David Mudrak added a comment - 02/May/08 04:57 AM
I can reproduce the problem on my MOODLE_19_STABLE development installation. If I follow Ann Adamcik's steps, I finish with the corrupted course content (empty course_modules). MDL-14326 does not help here because it deletes unoccupied course_modules only if $status is false (an error has occured). But in this issue, no error is thrown and the restore part of the import process finishes with $status = true; - until you go to the course.

Kenneth Newquist added a comment - 13/Aug/08 11:40 PM
I'm also seeing this issue, but the database fix mentioned in <a href="http://tracker.moodle.org/browse/MDL-10993">MDL-10993: Restore creates duplicate activity/resource icons with no text</a> did the trick for me with regards to getting rid of the ghost activities.

Claudio Gasparini added a comment - 18/Aug/08 12:07 AM
I get the same error message with one table.
I've deleted "id UNIQUE".
All seams working.
Everything seems to work. Have I done well?

Susana Leitão added a comment - 11/Sep/08 07:38 PM
I had exactly the same problem restoring a course by importing it to a blank course but using the "Import" admin functionality.
We are restoring all the courses for the new academic year...

"Turn off AJAX and delete the items." worked fine. But I still wonder if there's any problem with database as you mention above, and if yes what is the procedure to correct it.


David Mudrak added a comment - 11/Sep/08 09:54 PM
Please, try the most recent Moodle 1.9 weekly build and report if this is still the issue.

Ann Adamcik added a comment - 14/Jan/09 02:58 AM
We're still seeing this, using Moodle 1.9.3+ (Build: 20081223).

David Mudrak added a comment - 14/Jan/09 07:58 PM
Ann, can you send mi (via private email) a backup of the course? Or the link where I can download it and test it?

Ann Adamcik added a comment - 15/Jan/09 04:23 AM
This isn't specific to a particular course backup. I can consistently reproduce the issue on demo.moodle.org, by importing from the Features Demo into a new course. We've done some additional testing, and it seems that in some cases, the restore process can get launched twice, resulting in the empty modules.

Just before the restore part of the import starts, after the export from the "from" course is complete, there is a page titled "Import Course Data" with just a "(continue)" link. If the link isn't clicked within a few seconds, the page redirects and the restore launches. If the user happens to click this "(continue)" link twice, with maybe a half-second or so between clicks, duplicate icons will almost always occur. If the user clicks the link just before the page redirects, the problem will sometimes occur, depending on the timing. If the link is clicked just once when it first appears, or if the page is left to redirect on its own, the import works as expected.

It looks like there is some logic in backup/restore.php to prevent multiple restore executions, but it doesn't seem to be working quite right.


Petr Skoda added a comment - 15/Jan/09 04:49 AM
There was one bug in Course import - if you clicked on Continue link the restore failed badly. I suppose the same will happen if you double click on buttons. Is there any chance you did exactly this?

Michael Spall added a comment - 15/Jan/09 08:14 AM
Petr, I can get the duplicate items without text (ghost items) to happen with a single click on the continue link if it is timed so that the page redirect happens also.

Petr Skoda added a comment - 15/Jan/09 09:00 AM
You must not click on the "Continue" link during course import...

Michael Spall added a comment - 16/Jan/09 02:09 AM
Petr, I know not to click continue. But we keep having faculty that get duplicate items w/o text. We don't know for sure that using the continue is the reason faculty are getting the duplicate items without text, but it would be good to remove the possibility. Having a link called continue that you aren't supposed to click invites problems. Can the continue link and the redirect be removed and the code for the final part of the process be included in the same page. Or just have the continue link without the redirect. There are a series of continues earlier in the process.

Petr Skoda added a comment - 16/Jan/09 02:21 AM
Unfortunately I did not implement this hacky code We can not remove the continue, we could only replace it by continue button which would have to be always clicked, also this change would break some 3rd party automated scripts.

I do not know how to solve this


Ann Adamcik added a comment - 16/Jan/09 07:28 AM
I'm not sure about the implications for 3rd-party scripts, but we've come up with what might be a reasonable solution. This hides the continue link from the user and just lets the page redirect. Does anyone see any issues with doing it this way?

1. In our theme's stylesheet, I added the following so that the continue link doesn't display -

/* Don't display the continue link on imports */
#backup-restore #redirect #continue { display: none; } 2. I then added a message (should be a lang string) and a shorter timeout to the redirect - Index: restorelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/backup/restorelib.php,v retrieving revision 1.283.2.56 diff -u -r1.283.2.56 restorelib.php --- restorelib.php 18 Dec 2008 00:18:44 -0000 1.283.2.56 +++ restorelib.php 15 Jan 2009 15:40:52 -0000 @@ -7405,7 +7405,7 @@ }
else {
if (empty($noredirect)) { - redirect($CFG->wwwroot.'/backup/restore.php?backup_unique_code='.$backup_unique_code.'&launch=form&file='.$file.'&id='.$id); + redirect($CFG->wwwroot.'/backup/restore.php?backup_unique_code='.$backup_unique_code.'&launch=form&file='.$file.'&id='.$id, "Please wait...", 1); } else { return $backup_unique_code; }


Ann Adamcik added a comment - 17/Jan/09 03:42 AM
I just stumbled across MDL-15172. It looks like Petr and Tim already came up with the same solution as above.

Tiffany DeJager added a comment - 13/Feb/09 05:33 AM
I'm in version 1.9.3+ and had the same issue. Not clicking the continue to course button seemed to correct it. But it seems that the issues should just be corrected (also appears there is not a reliable hack to remove the continue buuton?)