(1.9 - 2.2) Broken URL. File.php problem on upgrade.

(1.9 - 2.2) Broken URL. File.php problem on upgrade.

by Angel MM -
Number of replies: 4

Well, moodlers, I'm having  a new problem with my upgraded site...

I'm not able to see any image in my server but I think I found the error: file.php can't access that resource with It's syntaxt.

http://moodleurl/file.php/1/title.png <== This returns error.

http://moodleurl/file.php?file=/1/title.png <== This works.

Wrong one is set in all courses (created in 1.9 version). Yes, I've tried with/without Legacy Course Files and with/wihtout Slash Arguments (which have to be enable because if not, course docuements (pdf, doc, etc.) are not accessible.

Thanks a lot for your replies smile

Average of ratings: -
In reply to Angel MM

Re: (1.9 - 2.2) Broken URL. File.php problem on upgrade.

by Ken Task -
Picture of Particularly helpful Moodlers

On a 19 site that works ... yikes, still in use! :\
Links to an image example in a course of a 1.9.19+ site:

<img complete="true" src="http://site/file.php/3/funnycompic1.jpg" alt="Funny" style="width: 402px; height: 202px;" title="Funny" vspace="0" border="0" hspace="0" />

Note after file.php/ a number.   That's the course ID number ... remaining of
the src link /funnycompic1.jpg is the file in humanly recognizable format that
was located in moodledata/3/ somewhere.

No longer true in version 2/3 in Moodle.
All files moved to filedir, are renamed for the contenthash of the resource,
(no longer found in filedir by a course ID number subdirectory nor by humanly recognizable names).

So in 2.2 you must leave legacy files turned on - site wide and in every
course until files have been moved from 'legacy'.

Historically .. there was a user that had discovered a 'work-around-way' to
rid a course of legacy, but one had to have no higher than version 2.3.2 ... after that version, the work-around no longer worked.  eg could not upgrade to 2.3.highest and expect the work-around to work. :\

There was a plugin for Moodle called poof.
Discussion:
https://moodle.org/mod/forum/discuss.php?d=276501
But I can't see to find it anymore via:
https://moodle.org/plugins/
to see if there was a version for 2.2.x .. think it came along later.

Once installed that allowed one to edit each individual resource to a file
that was broken and correct it.   Note the each individual resource.

So now comes the questions for they kinda determine where you go from here.

How many courses are we talking about?

Think the strategy now is to spin up a new/fresh 3.x and rebuild courses rather
than attempt migration from 1.9.anything up through versions of 2.x.
BTW, truely the only way to do that efficiently is via git but it means
the first step would be to move the 1.9.x site under git so one can upgrade
it to the highest 1.9.19+.  Then 'march' the site through stages.
Been there.  Done that.  It does work.   But, one still has legacy at the
end. :\

In anticipation of a logical question to ask .... can I restore a 1.9 backup
to a 2.x or 3.x?
Answer: possibly ... but ... here it comes ... you end up with legacy still.
And loose users/roles, etc..

Are you on Linux?

Are you averse to using command lien?

Are you desparate enough to try something I'm calling 'clipoof' on one course?

and last ... you might be restricted from doing this ... but have a server where we could test the 'clipoof' on one course backup ... and then restore it to one 3.0,3.1,3.2 - if you are game.

'spirit of sharing', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: (1.9 - 2.2) Broken URL. File.php problem on upgrade.

by Angel MM -

Good morning, Ken, thanks for your response. We thought about doing manually backups in each course, but there are about 150 of them so it would have been sooo maddening.

What I did: In my journey to 2.7 / 3.2 Moodle from 1.9, after all the tries, I end up using moodle 2.2 replace tool and replaced all the occuerences matching file.php with file.php?file= and all broken links started working again. Maybe this is not the best solution but after that, pluginfile.php started working in later updates (2.7 and 2.2 new files).

I love Linux smile and I'd love to know what were you thinking with the "clipoof" thing.

Best regards smile

In reply to Angel MM

Re: (1.9 - 2.2) Broken URL. File.php problem on upgrade.

by Ken Task -
Picture of Particularly helpful Moodlers

Have been seeking a solution to 'legacy' files - one of the 'discovered' after affects of migrating a 1.9 upwards to the 2 series (many moons ago).   Site has legacy turned on courses have legacy turned on ... all files in those courses have 'legacy' designations.

Am almost willing to bet that at some point in time in the future, 'legacy' support will disappear.

So ... go into the course that you just fixed with the search and replace.
Is legacy turned on?

If you turn off legacy in that course do all links to files work?

If not, turn legacy back on.

Then take a gander at:
https://moodle.org/mod/forum/discuss.php?d=350435&parent=1414497

'spirit of sharing', Ken