Upgrading to 3.0.3 --The webpage... lost ?

Upgrading to 3.0.3 --The webpage... lost ?

by Joseph Mary -
Number of replies: 9

The webpage athttp://catholicism.org/moodle/pluginfile.php/484/mod_resource/content/9/H-I-II-2%20SAI%20Class%20Outline.pdf?forcedownload=1 might be temporarily down or it may have moved permanently to a new web address.


Hello,

After upgrading to 3.0.3. This is the message I am getting for all my pdfs uploaded as sources.

I have at least 200 pdfs and would rather not manually redo them. Please help.

And when I go to edit the resource I get this message: 

Cannot read file. Either the file does not exist or there is a permission problem.

More information about this error


Average of ratings: -
In reply to Joseph Mary

Re: Upgrading to 3.0.3 --The webpage... lost ?

by Ken Task -
Picture of Particularly helpful Moodlers

Upgrades to code shouldn't touch moodledata/filesdir/ where the files are stored with contenthash values (like  ... 86c63636df679da082fa3b490ed53fb6b383d089 and  *NOT* humanly recognizable names ... like "H-I-II-2 SAI Class Outline.pdf")

Would refer you to the page that moodle gives you:

https://docs.moodle.org/30/en/error/moodle/storedfilecannotread

The error is saying it can't find the file (which means the reference in the DB to it) *or*
the file (contenhash named) has a permissions issue.

**Was the system ever using 'Legacy Files'.**   If it was, make sure Legacy files is  turned on.

Then see if you can edit a link to a PDF?

Still same error ... well, we have some work to do ...

First, check the ownership/permissions on your moodledata directory ... especially the filedir directory
and subdirectories and files in filedir.  Everything in there should be readable/writable by the apache user
of your system.

To find that file specifically is an adventure ...

With whatever tool you have to query the DB for your Moodle run the following query:

select contenthash,filename from `mdl_files` where `filename` like "H-I-II-2 SAI Class Outline.pdf"

That should display something like:

contenthash        filename  
86c63636df679da082fa3b490ed53fb6b383d089     H-I-II-2 SAI Class Outline.pdf

Then, using whatever you have for a tool to search for files in moodledata/filedir/
try to locate the file by contenthash name: 86c63636df679da082fa3b490ed53fb6b383d089

Below is an example from command line as root user in a moodledata/filedir directory:

find ./ -name 86c63636df679da082fa3b490ed53fb6b383d089

will display:
./86/c6/86c63636df679da082fa3b490ed53fb6b383d089

so it finds a physical file.

To see ownerships/permissions on that file from same location as above:

ls -l ./86/c6/86c63636df679da082fa3b490ed53fb6b383d089

Using example, the above command would show:

-rw-rw-rw- 1 apache apache 974339 May 29  2015 ./86/c6/86c63636df679da082fa3b490ed53fb6b383d089

On a CentOS system, this is correct.   apache user and apache group and rw means Moodle
should be able to see/find the file.

To see if the file is a PDF:

file -b  ./5e/d7/5ed7a6b2315954edbf9165e84f7f2db60544516f

should respond with something like:

PDF document, version 1.3

'spirit of sharing', Ken

In reply to Ken Task

Re: Upgrading to 3.0.3 --The webpage... lost ?

by Joseph Mary -

Legacy files was never turned on.

We cannot edit links to the PDFs.

Here is the permission for moodledata folder:

t


The subfolders had all options checked.

In reply to Joseph Mary

Re: Upgrading to 3.0.3 --The webpage... lost ?

by Ken Task -
Picture of Particularly helpful Moodlers

Well, thanks for that, but it's *half* of what I asked you to check. :\

I see that from the permissions tool you are using (I don't recognize what that tool is) that moodledata has a user that can see/do all, but what/who is the user?   Apache?   A login account name?  I see 755 which is pretty liberal.   But where is moodledata located?   /var/www/ ? or some other location.

Yes, know you've already said you cannot edit a PDF link ... and the error suggest either permissions *OR* the contenhash named file is no longer present in filedir/   The files are no longer saved with humanly re-cognizable names.   They are saved with filenames taken from the contenthash value in the DB.

Did you run the query on the DB so we can see the contenthash value from the DB?

From the example previoiusly given ... the query found contenthash value for the file you were trying to edit as "86c63636df679da082fa3b490ed53fb6b383d089".   The file itself is located in:

moodledata/filedir/86/c6/ and it's name is now "86c63636df679da082fa3b490ed53fb6b383d089" to Moodle.

Do you have something to browse files?

Also, check permissions of the user ... user is admin/teacher?

Site Admin -> Users -> Permissions -> Check System Permissions

Select user you were using.   The use the 'fllter' for the word 'edit'.

A site admin user should have all permissions to do all things.

If that doesn't show you anything ....

Turn on Debugging ... all the way to developer and then go attempt to edit a PDF link same one you did before.

If there is any debug output, copy the text ... come back here ... paste the text in a response.

'spirit of sharing', Ken



In reply to Joseph Mary

Re: Upgrading to 3.0.3 --The webpage... lost ?

by Ken Task -
Picture of Particularly helpful Moodlers

Op has granted me access to site ...

site is running el6.x86_64 (Red Hat Enterprise OR CentOS 6)  5.4.4 of PHP with Suhosin v0.9.36.

Weird ... in the one course tested ... some PDF files are there ... some are not.  No apparent issue with the way they are named.

Am wondering what apache error logs look like but as we know, Moodle Admin UI doesn't show that sort of thing.

However, it's been some time since I've seen Suhosin on a CentOS 6 box ... am wondering if it's needed with version 5.4.4 of PHP.

So unless anyone else has ideas ... am going to suggest turning off Suhosin ... might have to get provider support to do that.   Restart apache service.    Then see what happens.

'spirit of sharing', Ken


In reply to Joseph Mary

Re: Upgrading to 3.0.3 --The webpage... lost ?

by Ken Task -
Picture of Particularly helpful Moodlers

While there might be other ways, the only way I can think of where Moodle looses files from filedir is in the case where an older moodledata directory was restored to the site *without* a DB dump restored that was created the same time the data directory was backed up.

That would account for some files being present and some being missing.   The linking to obscured files collected in filedir is all controlled by the DB ... a bunch of meta data.

Running a backup of the course will render errors about those same files (the ones you cannot edit) missing and thus not included in the backup.   So restoring that course to a new course and then correcting those links to PDF's might be a time saver.   But, don't know how that affects a live course where students might have already completed a 'task' upon restore.  Running a backup, however, does show the path to the files ... and their contenthashed names.   One could copy and paste that info into a text file to use the info as a roadmap to manually re-create a 'missing file' that is 0 bytes.

This is also why one cannot edit such a link ... can't find the file.   While you say you have many PDF's it's not all files that are missing.   So you'd have to re-upload/re-link only the ones that you cannot edit.

Since you have completion turned on in the courses, it would also mean one might have to double check those rules for completion cause one cannot insert a link to a file at the place where it currently resides.  Drag and drop the resource into the position desired may not correct the sequence rules.

The only other way to fix is pretty 'guruish' ... find the content hash file that's supposed to be there ... the location in filedir as well as it's contenthash name. Then manually re-create the path if path doesn't exist as well as an empty file by contenthash name making sure the ownerships/permissions are correct when re-creating.   Since something can now be found, editing will be allowed and one can simply remove the reference to the file (really just a 0 byte file) with the real PDF file desired.   While that sounds like a lot of work, and it is, 'method' above might save you some time in re-ordering/sequencing, etc. completion settings for the course/file.

Unless someone else has ideas ... others are more than welcome to jump in here! ;)

'spirit of sharing', Ken

In reply to Ken Task

Re: Upgrading to 3.0.3 --The webpage... lost ?

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

That was my first thought - that this had been migrated or something though this thread stated it was just an upgrade?  

I had a site with a similar issue but it was after a migration that I did not handle.  Some files were there, some were not.  Unfortunately, in that situation, we ended up reuploading the missing files.  Perhaps there was some way to find them but luckily it only had a few courses and it was quicker to just add them back in.  

In reply to Joseph Mary

Re: Upgrading to 3.0.3 --The webpage... lost ?

by Ken Task -
Picture of Particularly helpful Moodlers

Did some backups of courses to see which ones reported files missing.
Had to have error reporting turned on to get specific information.
With error reporting off, only a notice about some files missing and wouldn't be included.

For the backups, included only activities and resources + quiz bank
With debugging turned on courses would backup but then report the errors indicating which files
were missing.

Below is a listing of one with the path to moodledata obscured a little:

S102 (the course short name)

Missing file in pool: /S-I-II-1 SAI Outline.pdf (context 716 'File: S-I-II-1 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/9d/3c/9d3c7aa9849bf3258261b1e4eda6194f59330b2a]
Missing file in pool: /S-I-II-2 SAI Outline.pdf (context 719 'File: S-I-II-2 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/89/4a/894af73cd7d375bafdf6785b8b5d15c12982ead4]
Missing file in pool: /S-I-II-3 SAI Outline.pdf (context 722 'File: S-I-II-3 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/83/cc/83cc60472a34eec69f380148dd48d0219294747b]
Missing file in pool: /S-I-II-4 SAI Outline.pdf (context 725 'File: S-I-II-4 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/b4/c6/b4c6e320daec81956dd695ea565833825a4b0ee2]
Missing file in pool: /S-I-II-5 SAI Outline.pdf (context 728 'File: S-I-II-5 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/2b/b9/2bb9cb8c5f774598bfd9ca4647beaaff49889784]
Missing file in pool: /S-I-II-6 SAI Outline.pdf (context 731 'File: S-I-II-6 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/54/23/54237eeb3cee396baec4a4b509414c1510f71c3c]
Missing file in pool: /S-I-II-7 SAI Outline.pdf (context 734 'File: S-I-II-7 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/6c/ef/6cef5b68b5ca160ffc646b2349fe0fd765822590]
Missing file in pool: /S-I-II-8 SAI Outline.pdf (context 737 'File: S-I-II-8 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/be/48/be48a99dff6b051ab7f586689c87fe48991ed303]
Missing file in pool: /S-I-II-9 SAI Outline.pdf (context 740 'File: S-I-II-9 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/40/ab/40ab3030cc0299a9719bb0838f96f669ec6a6f32]
Missing file in pool: /S-I-II-10 SAI Outline.pdf (context 743 'File: S-I-II-10 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/1b/5d/1b5ddfdd716791538401b3cbaabf0fef0a17b811]
Missing file in pool: /S-I-II-11 SAI Outline.pdf (context 746 'File: S-I-II-11 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/fb/6d/fb6d81d75b422b1b5c1b6975153acf2d9180c4eb]
Missing file in pool: /S-I-II-12 SAI Outline.pdf (context 749 'File: S-I-II-12 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/d9/2d/d92d2a2b09c5b0c7b0314b6a252d0b22cbd16a73]
Missing file in pool: /S-I-II-13 SAI Outline.pdf (context 752 'File: S-I-II-13 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/55/80/5580760f43845088b14fd3ff65cd7379f9d88c19]
Missing file in pool: /S-I-II-14 SAI Outline.pdf (context 755 'File: S-I-II-14 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/ff/65/ff65814f02a5d51bec54031649ae11c8f1d8957b]
Missing file in pool: /S-I-II-15 SAI Outline.pdf (context 758 'File: S-I-II-15 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/75/92/7592b9bf5d08377f30089931b8dd19803583c322]
Missing file in pool: /S-I-II-16 SAI Outline.pdf (context 958 'File: S-I-II-16 Outline', component mod_resource, filearea content, itemid 0) [/pathtodata/moodledata/filedir/d9/52/d952c2dbbec64e3756693fa4ff5f21a3deba88af]

I did 4 like this ... all had the same issue.

Bottom line ... my suggestion to put 0 byte files at locations where Moodle is expecting to find them etc. is very time consuming and would require a level of access not within Moodle UI.   It would/might be prone to human error (even if one were very experienced with Moodle and operating system upon which this site resides).

Thus, think replacing them via Moodle UI is a safe way to go.

I know that's not what you wanted to hear ... but there  is no magic button, etc. that will un-do this.

The only thing that would work is the moodledata/filedir directory that matched the DB.

Oh ... please remove my account from your system.

'spirit of sharing', Ken


In reply to Joseph Mary

Re: Upgrading to 3.0.3 --The webpage... lost ?

by Ken Task -
Picture of Particularly helpful Moodlers

OK, one other possible fix but **only IF**:

1) the site you upgraded was a 2 or eariler version of 3 AND

2) you did a full site backup which included the data directory.  

A full site backup is always recommended on upgrades.

*IF* the above conditions are NOT true, stop ... forget the rest of this:

*IF* the above two conditions are true, then ...

Extract from your full site backup just the data directory **but** do NOT replace the current moodledata directory.   Let's say you did that in /home/[youraccount]/backup/.

Then rename the un-archived moodledata directory to moodledata2.   Move the moodledata2 directory to the same level as your current moodledata.   

Example:

/home/[customerlogin]/public_html/ has the current moodledata directory.

Move the moodledata2 directory to /home/[customerlogin]/public_html/ ... same level

So you'll end up with a moodledata AND a moodledata2 directory at the same level of the folder structure of your site.

Then, edit the config.php file to point to /home/[customerlogin]/public_html/moodledata2/

Check ownerships/permissions on moodledata2 recursively.

You do NOT need to restart any service, just  hit site with browser and check out a course that was missing files.

Fingers crossed.

'spirit of sharing', Ken

In reply to Ken Task

Re: Upgrading to 3.0.3 --The webpage... lost ?

by Joseph Mary -

Thank you Ken for being there. 

Knowing  barely enough to upgrade doesn't help when things don't go smoothly.

The reason some files where showing was I had started to re-upload them some of them.

One strange thing was that when going to add files from the upload dialog window. the folders for the pdfs were there but the pdfs were not.

I will simply redo the files.

Thank you again Ken for being there. It is reassuring that moodle users have someone to run to in time of need.

Enjoy the sun of Texas!