Restore problem. ID don´t change on resource or image links

Restore problem. ID don´t change on resource or image links

by Daniel Costa -
Number of replies: 14
Hi everybody,

I'm using a moodle instalation 1.9.4. from 3 weeks ago. I'm having the following problem:

When restoring a course into a new course, the image and resource links are broken. Looking the links I can see that it's calling the old course id, not the new one. For example:

a course with id= 35 have the image links like: http://avirtual.forempv.ccoo.es/file.php?file=%2F32%2Fimage.jpg, where 32 is the id of the old course from wich I did the backup.


I saw several posts with more or less the same problem, but I could'nt see any clear solution or could'nt see any explanation that there isn´t a solution now to this problem. I could'nt find this on the tracker.

I would be glad to know if there is any solution to this, because i and I'm having to change by hand the id number of all the images and resources.

Thank's in advance
Average of ratings: -
In reply to Daniel Costa

Re: Restore problem. ID don´t change on resource or image links

by Russ Williams -
There are a lot of us having problems with the restore function, and it's not confined to differing versions. I and another user are having issues backing up and restoring current installation courses.
There has to be a Moodle guru out there somewhere that can find the bug. At least I hope so, since I live and die by the backup and restore functions.



rrw
In reply to Russ Williams

Re: Restore problem. ID don´t change on resource or image links

by Abraham Ott -
"There has to be a Moodle guru out there somewhere that can find the bug. At least I hope so, since I live and die by the backup and restore functions."

I'll second that. Our entire model of use rests on it.
In reply to Russ Williams

Re: Restore problem. ID don´t change on resource or image links

by Paul Nelson -
Here's a link to a PDF that at least shows users how to correct the problem (at least fixing the links, it does not address the cause of broken links.)

Note the link in the URL:
http://online.lmc.ac.uk/file.php/1/Documents/PDF/Moving_your_Old_Moodle_course_to_New_Moodle.pdf

If you were to move the course containing this resource to another server and restore it, it would restore the course but NOT change this part of the URL: http://online.lmc.ac.uk/file.php/1/ Since the resource was trying to pull a document from another server, the link fails. I see this all the time with images.
In reply to Daniel Costa

Re: Restore problem. ID don´t change on resource or image links

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Daniel,

and can you specify WHERE exactly are you using that image? In the course page? Within some section, or label? Or in some activity, which one?

Would be possible for you to generate one backup file causing problems on restore to you (without user info at all) and attach it to the Tracker, specifying the non-converted link/s there? Feel free to put here one reference to the bug in the Tracker once created.

That will help a lot to find the problem. TIA and ciao smile

In reply to Eloy Lafuente (stronk7)

Re: Restore problem. ID don´t change on resource or image links

by Daniel Costa -
Ok, no problem,

I can specify here where I'm having this problem. All images or links, inside a lesson or assignment or even outside, every place where the backup restore have to get the old id and change it for the new id present the bug.

And the tracker link: http://tracker.moodle.org/browse/MDL-18799

TIA
Average of ratings: Useful (1)
In reply to Daniel Costa

Re: Restore problem. ID don´t change on resource or image links

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Daniel,

thanks a lot for your quick and complete info in the Tracker (MDL-18799). cool

As commented there... I think the root problem are those %2F encoded chars in your URLs. They simply break backup links detections and later, restore doesn't find anything to transform back.

While I think we can modify backup easily to be able to detect also URLs containing those %2F encoded chars... it would be really interesting to know how you've ended with them there.

IMO the origin of the problem is exactly that, and we must avoid links being saved to DB using that encoded format, so any insight about how you have introduced them will be welcome.

re-TIA and ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Restore problem. ID don´t change on resource or image links

by Daniel Costa -
Hi Eloy,

I introduced them using the html editor. In case of images the tipical image insertion and in the link case the tipical link insertion, just like this one.

Thank's for the quick answer. I understand what you say, but still I don´t know how to solve the problem. I'm looking forward to receive some practical advice on this subject.

TIA and ciao wink
In reply to Daniel Costa

Re: Restore problem. ID don´t change on resource or image links

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Daniel,

but, for example, if I link here to one image in the course files:

I support Moodle
()

I don't get those %F2 chars at all in the HTML generated by the editor (using Firefox here). I get "normal" (correct) slashes.

Can you confirm, by inserting images from different browsers, if all them use to create the %F2 chars? Or can that be isolated to one/some browsers?

I think those chars can cause problems, not only in backup and restore but in other places. That's the reason to ask a lot about them. To be able to find the origin and fix it once and forever. Any info about that will be welcome.

In any case, I've planned to add support for those %F2 chars in backup and restore tomorrow (today is testing day and nothing can be committed). So follow MDL-18799, where the patch/fix will be added/notified.

Ciao smile

In reply to Daniel Costa

Re: Restore problem. ID don´t change on resource or image links

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Uhm Daniel,

I should read posts more carefully...
I should read posts more carefully...
I should read posts more carefully...
I should read posts more carefully... sad

Just saw that, in you previous posts, you're talking about URLs not using slash-arguments, i.e. of this type:

http://yoursite/file.php?file=/path/to/some/file

instead of the ones using slash-arguments (my example above):

http://yoursite/file.php/path/to/some/file

So, in you server, it's normal to have all those URLs showing the slashes converted to %2F, because they are part of one parameter (file) that needs to be properly escaped.

So, please, don't get stressed looking for browser combinations causing the "problem", because it isn't a problem, but expected behaviour in sites with your configuration (not using slash arguments). All the browsers will show the %2F chars in your server.

Said that, I'll try to see how we can handle those conversions in backup and restore in order to have those links working when transferred to other sites ( no matter of the slash-arguments setting). It's going to be a bit more complicated than I thought initially. Will continue at MDL-18799.

Ciao smile
In reply to Daniel Costa

Re: Restore problem. ID don´t change on resource or image links

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi,

I've sent one fix for this issue (happening on servers with $CFG->slasharguments disabled, afaik) to CVS some minutes ago (see MDL-18799 for more info). Now any combination of that setting should be transparently handled by backup & restore. Any testing and feedback will be welcome.

TIA and ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Restore problem. ID don´t change on resource or image links

by Pedro Crispim -
I am using slasharguments and my backups are now working!
In reply to Eloy Lafuente (stronk7)

Re: Restore problem. ID don´t change on resource or image links

by Michael Buchanan -
Hi,

I have backed up a course (ID 181) which has the %2f in the resource link URL's. The Moodle version is 1.93.

Here is how one resource link looked in the course before I backed it up:

<a target="_blank" href="https://mysite.org/file.php?file=%2F181%2FReadings%2FMydocument.pdf" title="Nida Phonemics explanation">

I restored the backup file to a system running version 1.95 but the %2F is still present and the document is still linked to the old course.

Should the fix for MDL-18799 have fixed this or does the site that I'm backing up from also need to be 1.95?

Thanks!
In reply to Michael Buchanan

Re: Restore problem. ID don´t change on resource or image links

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Yes Michael,

the bug MDL-18799 was fixed for 1.9.5 and it was a backup bug, not a restore one, so you need to perform the backup from one Moodle 1.9.5 (or above) installation (with latest weekly - that having one nice "+" after the version - being always the recommended one because it includes more fixes since the 1.9.5 -plain - release)

Ciao smile

In reply to Eloy Lafuente (stronk7)

Re: Restore problem. ID don´t change on resource or image links

by Michael Buchanan -
It worked! I backed up the course in 1.9.5 and the %2F's were taken out.

Thanks!