Restore creates links to "ghost pages"

Restore creates links to "ghost pages"

by ben reynolds -
Number of replies: 16
I've noticed this when restoring a 1.9 to 1.8 and when restoring 1.9.1 to 1.9.1

We have a template course using lessons. Within the lessons are links to forums, quizzes, and assignments. Each activity has a link back to a particular page in the lesson. All the links work fine in the template course.

When we use restore to create a new classroom, some of the links continue to point to the template classroom. Other links point to "ghost pages." Example:
this page doesn't exist
http://bluejay.cty.jhu.edu/mod/lesson/view.php?id=3800&pageid=4468
It is really this page
http://bluejay.cty.jhu.edu/mod/lesson/view.php?id=3800&pageid=5687

Nevertheless, the ghost page displays the content of the real page. You can tell it's a ghost page because the lesson's left side navbar title for the page remains an active link instead of turning black. And, frequently, the ghost page will have a link pointing to the template.

So, are the ghosts temporary pages that haven't been deleted, or what?
Average of ratings: -
In reply to ben reynolds

Re: Restore creates links to "ghost pages"

by ben reynolds -
I can't believe no one else has ever had this experience.
In reply to ben reynolds

Internal Links don't work when the course is copied

by Chris Collman -
Picture of Documentation writers
Hey Ben,
I saw your post in the Lesson Forum and decided to answer it here.

I have your issue happen to me. Linking internally to Moodle pages is tricky and seemingly inconsistent. A couple of years ago I really played around with internal linking. Both linking within a course and linking from the content area of one lesson page, to a Lesson page in a different course (itself library of unrelated tutorials or hints for a department). I think I even tried the template course idea with linking. And I don't think internal linking held through upgrades either.

Sorry.

No expert, I always thought the pageid= was something like a relative address vrs an absolute address in your favorite spreadsheet. You could set the link in one course but as soon as you copied or imported something into another course, all links like that became suspect. I never understood why some worked and some did not. It was like the MySQL database reindexed some and not others. Yep, I do not do code.wink

As I recall, the ghost pages also happens when restoring a course to a different server/Moodle site.

A more technically inclined person probably can give us a better answer. You are not alone.

Best Chris




Average of ratings: Useful (1)
In reply to Chris Collman

Re: Internal Links don't work when the course is copied

by Jerónimo Visñovezky -
Chris,
I'm sorry to disturb you with almost the same question again but I just want to confirm I got your post right. I have just spent no less than 4 hours reading threads that deal with absolute/relative paths because I'll be helping some teachers put together a course that is heavily linked to it's own activities and resources. As we know we'll be duplicating this course in the future, I wanted to make sure links to it's own forums, quizzes and chats was not going to be a problem.

Unless I've skipped something important, it seems there is no way to use some sort of relative links that will resist duplication.

Yet, the need to be able to link activities within a course seems so predictably simple that I can't believe moodle won't just convert these links to reflect the new modledatta subfolder/course ID upon course import. In fact, I'm just about to try and see if my 1.8.4 does not do just that.

But, in case I fail, I want to confirm with someone that has tried it before that there is no way around this and that internal linking (adding links by hand I mean) shoud be avoided whenever possible.

A yes or a no will do. Thanks for your time!
In reply to Jerónimo Visñovezky

Re: Internal Links don't work when the course is copied

by ben reynolds -
Here's a sort of update. In a 1.8.2 to 1.8.2 restore, Moodle translates the links just fine.

I'm guessing this is a 1.9 problem. I submitted a bug report , but no one has taken an interest sad

This problem only exists for links from an activity to a lesson page. Links out of a lesson are translated properly.
In reply to ben reynolds

Re: Internal Links don't work when the course is copied

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Ben - I do not think it is fair to say that no one has taken an interest. I suspect that the reality is just a lack of time especially with the major focus being on developing Moodle 2.0. A certain amount of triage is done to focus on issues that have a higher priority or that are more popular (i.e. have a number of votes). As a result, some issues may seem to sit around for a while before someone gets to them. I know that we are all doing the best we can. I have commented on MDL-16973 and if others are also experiencing this problem or interested in having it fixed they can vote and watch that issue. In the meantime, if there is anything I can do to be of help just let me know. Peace - Anthony
In reply to Anthony Borrow

Re: Internal Links don't work when the course is copied

by ben reynolds -
Hi Anthony,
Let me add that my little sad face was intended to be self-deprecating.

I do understand the necessity of triage. And agree with it.

Finally, I also want to say that the Moodle community is pretty darned good.
In reply to ben reynolds

Re: Internal Links don't work when the course is copied

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Ben - Thanks for clarifying. I read the sad face as you were sad with Moodle. I've taken a look at the issue and will comment in the tracker on any progress/questions. I tend to think the community is pretty darned good too. Thank you for being a part of its goodness. Peace - Anthony
In reply to ben reynolds

Re: Internal Links don't work when the course is copied

by ben reynolds -
Correction: in 1.8.2 the links are not translated properly.

I just retested in 1.8.2, and the links failed.

Apologies for running on memory.

And thanks to Anthony for working on this problem. He has useful comments in the tracker.
In reply to ben reynolds

Re: Internal Links don't work when the course is copied

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Ben - Thanks for verifying it was in fact not working in 1.8.2. It should not be overly difficult to do but will require a little bit of thought to check for the presence of the page id and get the new one. The information needed is already in the backup so we just need to focus on the restore process. After replacing the module id, we need to see if pageid is part of the resulting link and if it is go get the new pageid and replace the old with the new. Peace - Anthony
In reply to Anthony Borrow

Re: Internal Links don't work when the course is copied

by Allen Cole -
Dear Ben and List,

Just wanted to comment here on this "restore" issue. To me and for I imagine many in my position, this issue is one that is quite constant. I am not a programmer in PHP and do give great thanks to all who work in this open source environment, constantly working to improve this software. Most of us need to "restore" classes two or three times a year, as we offer our courses from semester to semester. To have the restore not work as expected was a jolt. We need to go in and "fix" most of the internal links in a course. My main issue with the restore was one of images not working (being displayed) in the restored course. Here is a copy of the discussion thread I posted a month ago here (and gave what I thought was an answer - but may not be now). I copy it here - just to add to the complexity possible of the restore issue fix...because I believe if this issue of "ghost pages" gets looked at - then this issue I describe is a part and another itteration of that same re-store error...just thought they are and probably should be linked together...

Anyway here was/is my issue (copied from an earlier posting):

I have a restore problem – dealing with image referencing – that I wonder if anyone is having a similar issue.
Our server is currently running at version: Moodle 1.9.2+ (Build: 20080827)
The issue is that when I do a back-up of a course and then re-store to a new course all of the images still reference to the course ID of the backed-up course rather than the new course. This means that none of the images are showing to the new students in this new class – seems to be a permissions problem, since they are not enrolled in this “old/original” course. But if I go in and enroll them in this old/original course the student can see the images in both classes – even if I do not change the image source reference to reflect the new course ID

For an example here is the image source I am seeing in the new course:



In reality, the course id of this restored course is actually 322. If I go in and re-link this image – all is well. (all it does is change the course ID in the image source code)

Before we were at Moodle version 1.9.2+ - whenever I did a restore from back-up the course ID seemed to change correctly during the restore to new course (which is what I assume is the correct process) and there were no image problems. I have earlier restored easlily a hundred courses correctly – this problem has just seemed to begin occuring.

Any ideas? Some setting somewhere? Incorrect creating of the image referencing in the first place?
Thank you VERY much if you have any ideas and feel like sharing!!!

Allen Cole

My Reply to myself:

OK, I'm going to try to give an answer to this issue - that MAY be what is happening. A number of our classes were written/created in an earlier version of Moodle (1.8?, I believe). We are currently using Moodle 1.9.2+. within the last few months we made this upgrade on to a different server (and different server name) Then we moved our courses over.

In Moodle 1.8 an image source code could look like this:

Example 1

file.php?file=/40/Images/firststep.gif

Currently, on the 1.9.2+ server the image source code looks like this:

Example 2



Note: the no "?file=" code

If you leave the course to be backed-up with the sample image code written as in sample one the back-up and eventual restore will NOT change the image source code to the NEW course ID. This leaves broken images.

If I make the change to reflect the Example 2 image source code (on this currently used Moodle 1.9.2+ server) It will change the course id to the new course id during the restore.

I am not sure if anything can be changed in the backup and restore php code to help this issue for me...otherwise I need to go in and fix the images in a lot of courses...

Anyone know?

Thanks
Allen Cole

Again Ben - this is not a complaint - but just informative to what I think is part of the restore issue in the PHP code...but not being a programmer - I truly don't know - or how to fix it - other than to go in and change the course ID...

Sorry to be a little long winded here.

Allen Cole
E-School - Hawaii Department of Education



In reply to Allen Cole

Re: Internal Links don't work when the course is copied

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Allen - Thanks for sharing the issue you were having with the restore and for being part of the Moodle community. Could you check and see if an issue is filed for the issue you described. It is a separate but related issue and backups and restores are complicated business but I definitely hear what you are saying about being jolted when a restore does not work as intended. As they say, the backup is only as good as the restore. If there is not an issue in the tracker for the issue you described, please create one so that we can look into what is preventing the restore from working correctly. Please do not hesitate to let me know if there is anything I can do to be supportive. Peace - Anthony
Average of ratings: Useful (1)
In reply to Allen Cole

Re: Internal Links don't work when the course is copied

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The difference with, and without, the ?file=, is to do with the 'Use slash-arguments' admin setting.

The problem that backup and restore has to solve is that a lot of URLs in Moodle, for example, .../course/view.php?id=123, contain the id of something in the database, and this will almost certainly change during backup and restore. Also, $CFG->wwwroot may change.

The solution adopted is, that during the backup, all URLs are encoded to a symbolic form. I can't remember exactly what it is, but it is something like $%COURSEVIEWBYID-123%$.

Then on restore, that is turned back to a real URL, using whatever the correct ID that course 123 got restored to.

There are only a few ways that this can go wrong:

1. When the backup is made, Moodle forgets to encode the URLs in that bit of content.

(For example, you can be pretty sure that something common like forum posts will be handled correctly, but perhaps the person to coded up backup and restore of shortanswer questions forgot to get links in the feedback for specific answers encoded correctly.)

2. Moodle fails to correctly encode a particular type of link.

(For example, common links like ../course/view.php?id=123 are sure to be handled correctly, but perhaps the link to review a particular student's quiz attempt is not encoded properly?)

3. and 4. are the mirror images of these:

3. Moodle forgets to decode links in a certain type of content when it is restored.

4. Moodle cannot correctly decode a certain type of link when it is restored.

To determine whether your problem is 1/3 or 2/4, try putting in a link to something common, like the course view page, into the content you are trying to backup and restore; alternatively, copy the problem URL into some content that you are sure is handled correctly.

To determine whether it is 1/2 or 3/4, look in the backup file. If you unzip the backup file, you fill find a file called moodle.xml in there. Somewhere in that XML will be your content, and you will be able to see whether your URL was correctly encoded. If it was, then the problem is at restore time. If not, then it is a backup problem.

(Hmm, I think I just typed something useful. Someone should probably copy this to Moodle Docs, with a title like 'How to diagnose backup and restore re-coding problems'.)
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Internal Links don't work when the course is copied

by ben reynolds -
Tim,
Quite definitely something useful that should be added to Moodle Docs! Who initiates this procedure?

Of course, I must ask questions to elaborate.
"To determine whether it is 1/2 or 3/4, look in the backup file. If you unzip the backup file, you fill find a file called moodle.xml in there. Somewhere in that XML will be your content, and you will be able to see whether your URL was correctly encoded. If it was, then the problem is at restore time. If not, then it is a backup problem."
By, "unzip," I am 90% certain you do not mean "restore." Rather, unzip to some innocuous folder. Right?

Once unzipped, a user would find the file "moodle.xml" and search that file for something like "Lesson 1," for example, where a URL to the course view page was embedded before backup.

Upon finding "Lesson 1," look at the URL and see whether it is
"something like $%COURSEVIEWBYID-123%$," meaning a symbolic link,
or whether is looks like
"../course/view.php?id=123." (Readers note: this is the right hand side of the link, not the whole link.)

If we see a symbolic link, the backup is doing #1, but not necessarily #2.

If we don't see a symbolic link, the backup is not doing #1 and therefore cannot do #2.

Am I correct about what we're looking for?

Last question: How do we know if the backup has done #2 correctly?
In reply to ben reynolds

Re: Internal Links don't work when the course is copied

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Ben - The Moodle docs are a wiki so anyone can go in and create a page. As for your moodle.xml file, the backup is fine (as best as I can tell). It does highlight the lesson link that needs to be replaced. The problem, as I've outlined in the tracker (MDL-16973), replaces the lesson id but it does not replace the page id. As I recall, the page ids were being backed up. Just not being replaced during the store. Peace - Anthony
In reply to Anthony Borrow

Re: Internal Links don't work when the course is copied

by ben reynolds -
For a guy who handles as much code as you do, your memory is very accurate.

It's the page id that needs to be replaced.

And, since you could see the lesson id properly translated in the restore URL, we know that this particular issue is in replacing the page id during restore.

But I think Tim's method is a good general approach for this kind of problem, especially if there's no Anthony Borrow reading the code.
In reply to ben reynolds

Re: Internal Links don't work when the course is copied

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Thanks Ben. Yes, Tim's description there was very good and definitely will make for good documentation as it explains well how to handle backing up and restoring internal links. Peace - Anthony