whole cache folder missing

whole cache folder missing

by Tim tkint -
Number of replies: 6

Hi,

all of a sudden the cache folder in the moodle 'system' folder (not moodledata) dissappeared, resulting in a white screen and error:

PHP Fatal error:  require_once(): Failed opening required '/home/####/public_html/moodle/cache/lib.php' (include_path='/home/####/public_html/moodle/lib/pear:.:/opt/cpanel/ea-php71/root/usr/share/pear') in /home/####/public_html/moodle/lib/setup.php on line 613

restoring the folder and the files within solved the issue, but I would like to know what happened here and how I can avoid it in the future.

Best,

Tim

edit: moodle version 3.8.3, php 7.1. There seems to be no sign of any malicious code or ftp-logins

Average of ratings: -
In reply to Tim tkint

Re: whole cache folder missing

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

I'll stick my neck out and say there's no way the unmodified Moodle source code will do this on a normally-configured site.

The only thing I can think of is: if the Moodledata cache folder overlapped with the one in the source code folder, e.g. either $CFG->dataroot was set to the source code folder, or $CFG->cachedir was set to cache in the source code folder (both set in config.php). In this case presumably when a cache purge occurred source code files in this folder would also be removed.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: whole cache folder missing

by Tim tkint -
cachedir is not explicitly set in config.php, just the dataroot (and that one is correct) also no changes to config.php recently.

In the meantime I found this very similar issue: https://moodle.org/mod/forum/discuss.php?d=372589, with the same suggestion of configuring datadir in addition to dataroot. what is the difference between those two?
In reply to Tim tkint

Re: whole cache folder missing

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
moodle/config-dist.php is the place to look for explanations. In my config-dist.php from Moodle 3.9 there is not a single reference to $CGF->datadir.
In reply to Tim tkint

Re: whole cache folder missing

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Concurring with what Visvanath says I don't think $CFG->datadir is a real setting, I think Howard meant $CFG->dataroot in his reply (Howard: please correct me if I'm wrong).

But in that old issue it looks like the source code and Moodledata cache folder were overlapping ('I did have "$CFG->dataroot" and it was pointing to the wrong location' – presumably to the source code folder).

You could check the contents of the cache folder in the Moodle source code folder to see if Moodle is using it for cache data by 1) seeing if it contains the folder cachestore_file or 2) manually purging all caches and seeing if the problem occurs again (take a backup of the cache folder first).

Beyond that I'm out of ideas.

In reply to Leon Stringer

Re: whole cache folder missing

by Tim tkint -
Thanks for your reply, the datadir will probably just be a typo then, couldn't find any reference to it.
I checked and in my case moodle is correctly using the moodledata folder for caching.
Furthermore not only the files within, but also the 'cache' folder itself was deleted in my case, which should not happen I think even if it is a case of mixed up folders?
In reply to Tim tkint

Re: whole cache folder missing

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Yes, the cache folder would only be emptied not deleted if Moodle's purge cache was performed.

I'm still fairly confident that deleting this folder isn't something Moodle could do.