Images not working - Upgrade from 3.4 to 3.8

Images not working - Upgrade from 3.4 to 3.8

by Steven Cohen -
Number of replies: 8

I just upgraded from moodle 3.4 to 3.8.  I also migrated from shared hosting to a VPS.  I migrated before upgrading and the migrated website was OK.  Now the images are not showing.  I have all other course material but the path to the images seems to be broken.

My website is:

retinauniversity.com

I'm running php 7.1 on a VPS.


Thanks,

Steve

Average of ratings: -
In reply to Steven Cohen

Re: Images not working - Upgrade from 3.4 to 3.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Try clearing caches...
In reply to Emma Richardson

Re: Images not working - Upgrade from 3.4 to 3.8

by Steven Cohen -

I purged the caches and the images are still not showing.

One other thing I did during the upgrade was to change the location of the moodle data directory and rename it.  I had been in a shared hosting environment which required the moodle data directory to be in the public_html folder.  In the VPS, I was able to place the moodle data directory one level above the public_html folder which is what is recommended.

That might have messed up the path to the images (although it seems that everything else is working OK.

I appreciate the help.

Happy Holidays,

Steve

In reply to Steven Cohen

Re: Images not working - Upgrade from 3.4 to 3.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Did you change the location in the config file? Have you checked permissions? The other thing you might check is the setting for the use of slash arguments...
In reply to Steven Cohen

Re: Images not working - Upgrade from 3.4 to 3.8

by Chamika Ranasinghe -
Dear steven ,

Please check memory limitations .
read this carefully please ,
https://docs.moodle.org/38/en/PHP
In reply to Chamika Ranasinghe

Re: Images not working - Upgrade from 3.4 to 3.8

by Steven Cohen -
My moodle had been on a shared hosting server and the moodle data file was therefore in the public directory. When I migrated to a VPS, I put the moodle data directory one level up. I tried moving the moodle data directory back to the public_html folder like it was in the shared hosting and that got back some of the image files. I changed the path in the config.php file for the data. I'm not sure why the website loses images when the moodle data folder is moved from one place to the other. There are not a lot of images on my site and I can re-upload them all.
In reply to Steven Cohen

Re: Images not working - Upgrade from 3.4 to 3.8

by Ken Task -
Picture of Particularly helpful Moodlers

Now that you've made the 'leap' into VPS's, congrats! ... now a couple of things to check and find out.  (not all providers are the same and/or equal when it comes to supporting moodle because it ain't as easy as a WordPress, etc)

First, never remove the .htaccess file in your moodledata directory.   It is the only thing protecting it from public browsing.

Second ... make sure to check the setup of cron job and if it's running frequently enough.  On shared systems cron jobs might have been restricted to running every 30 minutes or so.  You should now be able to run the cron job every minute.   That sounds like it will overtax your new VPS, but it shouldn't as cron jobs in latest versions of Moodle have task ... which are parts of overall cron ... and have a schedule of their own.   Might want to look over that schedule as well.

In setting up cron, use moodlecode/admin/cli/cron.php.  That means you need to know the location of php-cli.

You should have an icon for ssh now in cPanel... and clicking it one should find themselves at a web based page terminal session with a command pompt.

Type: which php [ENTER]

The path you see there should be php-cli.   Check it by:

/path/you/see/php -v

In response you should see reference to php-cli ... that's the path to use in setting up cron job.  If you don't see anything about php-cli, check with helpdesk (may as well see how responsive helpdesk is concerning VPS systems).

You might not need it now, but may as well start the process cause you might have to 'reason' with helpdesk now.   Find out the superuser credentials to your DB server.  The user and password you see in config.php of moodle is NOT the superuser.   Why would you need this?   There are some command line scripts in moodlecode/admin/cli/ that are for your DB.  Some of them require super user credentials to the DB server.

If you have that 'nag' at the bottom of Environment check about database for Moodle, you can now 'fix' that with super user creds and a couple of those cli only scripts.

it's also a good idea now to learn how to backup your moodle via command line.

For starters: https://docs.moodle.org/38/en/Administration_via_command_line

Qualifications for this response: have been ask by individuals to fix things after VPS moves at times.  Above is information gathered from that 'experience'.

'spirit of sharing', Ken


In reply to Ken Task

Re: Images not working - Upgrade from 3.4 to 3.8

by Steven Cohen -

Ken,

Thank you very much for all that advice.  I could not send emails from my moodle site and learned that I was NOT running cron jobs on my VPS and that is why the emails wouldn't send.  Since then I set up the cron jobs and now the emails are working.  I think the images just got corruped somehow and need to be reloaded.  I had some trouble in the past with my moodle site and I think between 3 upgrades and migrating the website to the new server, the image path got lost in the shuffle.

If you know a command line script that might 'fix' the database in a way that the image paths might start working again that would be very helpful.  Either way, thank you for taking the time to help me.

All the best,
Steve

In reply to Steven Cohen

Re: Images not working - Upgrade from 3.4 to 3.8

by Ken Task -
Picture of Particularly helpful Moodlers

There isn't a cli script that specifically addresses the issue your site has.   But a clue is 'draft' status ... as opposed to other designator that is working.

Have you looked at scheduled task on your new site?

via CLI ... cd admin/tool/task/cli

php schedule_task.php --list

Will show all the task scheduled ...

2 might be releated ...

\core\task\cache_cleanup_task

\core\task\cache_cron_task

Due to moving of moodledata and thus filedir as well, check ownerships permissions on moodledata/filedir and all folders files in filedir.   They might have changed.

And using a known graphic file humanly recognizable name that isn't displaying, might query your DB to see what's up.

Use DB for Moodle, then query something like:

mysql> select filename,filesize,status,contenthash from mdl_files where filename like '%.png';

Run above first to see that works.

Then change filename like to filename='humanlygivenfilename.extention'

The image filename is, of course, the one that won't display.

Is it there in DB meta data?  Probably is ...

Now to see if it's physically in moodledata/filedir/

cd moodledata/filedir/

find ./ -name 'contenthashvalue' (as seen in query)

That command might take some to depending upon size of filedir.

Example:

| timeline.png                             |    15922 |      0 | 0d248ec0e528a005e139bf3a946254a81c16e55a

again using example data above:

in moodledata/filedir/

[root@sos filedir]# find ./ -name 0d248ec0e528a005e139bf3a946254a81c16e55a

should respond with:

./0d/24/0d248ec0e528a005e139bf3a946254a81c16e55a

bolded above is the real file in moodle filing system.

To get an idea if it is a png ...

[root@sos filedir]# file -b ./0d/24/0d248ec0e528a005e139bf3a946254a81c16e55a
PNG image data, 352 x 260, 8-bit/color RGBA, non-interlaced

IF all above check out ... image should show! ;)

'SoS', Ken