file problem after upgrade - update with debugging

Re: file problem after upgrade - update with debugging

by Mark Pearson -
Number of replies: 8

I have a similar problem which combined an update from 2.6 to 2.8 and a restore of Moodle production data into my sandbox server (just to test whether it would actually restore smile. Here's the actual problem and how I fixed it :

Home / ► Site administration / ► Appearance / ► Themes / ► More

More

Can not read file, either file does not exist or there are permission problems

More information about this error

Debug info: [dataroot]/filedir/41/cf/41cfeee5884a43a4650a851f4f85e7b28316fcc9


1. Ran the following in phpmyadmin : SELECT * FROM `mdl_files` WHERE `contenthash` LIKE '41cfeee5884a43a4650a851f4f85e7b28316fcc9' LIMIT 0, 25 ;

which extracted 9 records relating to the theme More.

2. Contents of containing dir :

filedir/41/cf % ls -lh

total 892

-rwxrwxr-x 1 theFN www 722K Dec 2 2013 41cf00ce91593edf51178a80de0279178615e66d

-rwxrwxr-x 1 theFN www 3.3K Apr 30 2013 41cf3a89a0900741fad47822af24bee0ca3020bd

-rwxrwxr-x 1 theFN www 118K May 18 2014 41cf8b2005e023d2d5d08a4264963e73263be24e

Notice that there's no file 41cfeee5884a43a4650a851f4f85e7b28316fcc9 which is what the error is complaining about.

3. How to fix? Had a brainstorm – Uninstall the More theme via Home / ► Site administration / ► Plugins / ► Plugins overview . This should remove any crap in the database. Since the code is still there when [Upgrade database] is clicked the records should be re-created & the files as well (in theory). So that is what I did.

4. WORKED. More is back and no errors.

Contents of filedir :

filedir/41/cf % ls -lh

total 900

-rwxrwxr-x 1 theFN www 722K Dec 2 2013 41cf00ce91593edf51178a80de0279178615e66d

-rwxrwxr-x 1 theFN www 3.3K Apr 30 2013 41cf3a89a0900741fad47822af24bee0ca3020bd

-rwxrwxr-x 1 theFN www 118K May 18 2014 41cf8b2005e023d2d5d08a4264963e73263be24e

-rw-rw-rw- 1 www www 4.3K Jul 10 12:45 41cfeee5884a43a4650a851f4f85e7b28316fcc9

Note change of permissions!

Did the same SQL select as above – extracted 16 records! All is good.

Hope this helps someone.

Mark

Average of ratings: Useful (1)
In reply to Mark Pearson

Re: file problem after upgrade - Migrated to a new server and files showing error

by Andrea Samadi -

Hello, thought I would post here incase I can find a faster solution.


I just migrated my moodle site to a new server, and get the error message when I try to click on any file.


I have asked my webhost (hostgator) to look again at the migration process, but is there something else I can do to fix this? I tried to go in and add the files back (I would do this if I could for a faster fix) but I cannot do this.


Any help, advice, tips? I'm hoping I can fix before students login.


Andrea Samadi



Attachment 2015-09-16_0535.png
Attachment 2015-09-16_0536B.png
In reply to Andrea Samadi

Re: file problem after upgrade - Migrated to a new server and files showing error

by Karrie V -

did you find an answer?  I just moved from hostgator as well and I'm having a similar issue.  

In reply to Karrie V

Re: file problem after upgrade - Migrated to a new server and files showing error

by Fernando Navarro Páez -
Picture of Testers

+1, from 2.5 to 2.8

In reply to Andrea Samadi

Re: file problem after upgrade - Migrated to a new server and files showing error

by Ken Task -
Picture of Particularly helpful Moodlers

The migration from one server to another ... what was old servers fully qualified domain name?

http://oldhost/

Is that different from the new location/hostname?

http://newhost/

IF this is the case, the URL's pointed to files in Moodle are built by taking the value of the wwwroot for the site thus in the DB one has http://oldhost/....blah/blah/file.   You can check this by placing mouse over the link and look at where it's going to retrieve that file.

When migrating to a new site/domain one must change all links to files.

So ... IF above is true ... do a dump of the DB (ie, get a backup of it before doing the following).  Might also research how to restore your DB should the following not work or you do this in-correctly.   The search and replace has to be 'exacting' and accurate or you'll mess up a bunch of stuff making it harder to fix.

There is a search and replace tool

http://newsite/admin/tool/replace/

You'll see a warning ... that's why the DB backup is important!

Search box: http://oldsite/ - make sure you include the full URL to the old site ... if site was running https then use https://oldsite/ ... make sure to include the trailing '/'.

Replace box: http://newsite/ or https://newsite/ - same thing include the full URL ... include trailing '/'.

That does a search and replace for URL's in a bunch of tables.

Once it finishes, navigate to one of those former errant links to see if that didn't fix it. ;)

This will not fix links one may have had in user created HTML blocks ... those you have to edit manually.

'spirit of sharing', Ken


In reply to Mark Pearson

Re: file problem after upgrade - update with debugging

by Matt Polaniecki -

I have the same problem after trying to switch over to another database.

1. I cloned MYSQL over to another database

2. I changed the info in config.php.

3. My courses and users were there, but I kept running into this error whenever I tried going to Site Home or to edit a course.

Debug info: [dataroot]/filedir/0a/32/0a3201a56aac42e796fd5e929bf0c2b8d85ce22d
Error code: storedfilecannotread
Stack trace:
  • line 579 of /lib/filestorage/stored_file.php: file_exception thrown
  • line 606 of /lib/filestorage/stored_file.php: call to stored_file->get_imageinfo()
  • line 55 of /theme/interactive/renderers/course_renderer.php: call to stored_file->is_valid_image()
  • line 83 of /theme/interactive/layout/frontpage.php: call to theme_interactive_core_course_renderer->new_courses()
  • line 1015 of /lib/outputrenderers.php: call to include()
  • line 945 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line 112 of /index.php: call to core_renderer->header()

Any idea? I did the SQL call and found 8 records relating to 0a3201a56aac42e796fd5e929bf0c2b8d85ce22d


Should I just delete them? Please help!

In reply to Matt Polaniecki

Re: file problem after upgrade - update with debugging

by Ken Task -
Picture of Particularly helpful Moodlers

What see in DB is metadata, so rather than just removing records manually without really knowing what one is doing (never advised) think I'd investigate a little more about the file that's in the DB but does NOT appear to be in moodledata/filedir/

So go to your moodledata/filedir/

Look for a directory: 0a ... change into it.

In side that diretory look for another directory: 32 - change into it.

Now list to see if there is a file by the following name: (command: ls -l)

0a3201a56aac42e796fd5e929bf0c2b8d85ce22d

We don't know what it is but from errors appears to be front page related so ... got any images on the front page NOT generated by theme?

While in moodledata/filedir/0a/32/ issue the following command:

file -b 0a3201a56aac42e796fd5e929bf0c2b8d85ce22d

That will give some brief info about the file.  If that info says something about .jpg or other image info, see what it is.

cp 0a3201a56aac42e796fd5e929bf0c2b8d85ce22d /path_to_web_server/document/root/where_modle/code resides/some.jpg (or .png - whatever file info said it's file type was).

Then, using a browser, go directly to that image ... http://yoursite/some.jpg

Recognize the image?

That same image could be linked in any of the courses.  Then the fun begins to find the course that used it.

'spirit of sharing', Ken

In reply to Ken Task

Re: file problem after upgrade - update with debugging

by Matt Polaniecki -

Thank you so much for your help. In PHPmyadmin I was able to see that the errors were all related to the .jpgs i had set for the Course Summary files. Since "Site Home" and "Edit settings" all call those course summary files, I was getting scary errors on those pages.

The fix was I simply deleted the courses and then re-imported them. Another reminder of how important backups are!

Thank you very much for your help. I gotta bookmark this page so I remember these commands for the future.