PHP Upgrade - Fatal error: $CFG->dataroot

PHP Upgrade - Fatal error: $CFG->dataroot

by Shawn Peters -
Number of replies: 13

So were just prepping for some summer updated and I updated PHP from 7.2.32 to latest 7.4.20 release and not Moodle wont boot at all.  Get "Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting." Error.

If I make the PHP v7.2.x files live again everything works perfectly.  What changed in the new PHP version to break this???

Also tried latest PHP v.7.3.28 with same issue.

Moodle is version 3.6.5  on Windows IIS.  Running on MySQL.

Yes the permission on 'moodledata' folder are correct and I even re-applied them just to make sure.  I'm really stumped.

PHP location is the C:\php\  I'm just moving the v7.2 or v7.4 files in/out of that folder to upgrade.   PHPinfo file loads perfectly, just Moodle wont.


Any ideas?  I've been banging my head for 2 days now and haven't gotten any further.


Thanks in advance,

Average of ratings: -
In reply to Shawn Peters

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Shawn Peters -
Still no idea what's going on, but put PHP v7.2.34 on the server and had no issues.
PHP v7.3.1 -- fails.... Fatal error: $CFG->dataroot

SO what the heck changed so much in PHP v7.3.x from v7.2
In reply to Shawn Peters

Re: PHP Upgrade - Fatal error: $CFG->dataroot

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

When switching to PHP 7.4 have you copied the php.ini that PHP 7.2 is using across to PHP 7.4?

In reply to Shawn Peters

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Shawn Peters -
Yes I copied the php.ini file and I even re-created a new one based on the new php.ini-production file. Both still failed.

I know PHP 7.4 isn't supported in 3.6.5, but PHP v7.3 is, so not sure why that's not working. I'm thinking I'll just have to stay at PHP v7.2 and only upgrade to Moodle 3.10.x for the time being.
In reply to Shawn Peters

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
If you are still at 3.6 then first update it to the 3.6.last which is 3.6.10.

Otherwise additional plug-ins which are incompatible with the newer PHP cause upgrades to fail.

You're on Windows, so can't say more. The other discussion you just joined https://moodle.org/mod/forum/discuss.php?d=411905#p1710261 is also about Windows. There could be a connection.
In reply to Visvanath Ratnaweera

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Shawn Peters -
Yes I'm running v3.10.5 now, on Windows. Ya not sure if the other post did find a resolution.

For now I'm stuck on 3.10 and can't upgrade to v3.11 until this get's sorted out. I'm running out of ideas. Tried messing around with php.ini settings and still no luck. I have no idea what changed in PHP
In reply to Shawn Peters

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
So you looked at Site administration > Plugins > Plugins overview > Additional plugins and it is empty, I assume?
In reply to Visvanath Ratnaweera

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Shawn Peters -
With PHP v7.3+ it doesn't load. Just that dataroot error.
PHP v7.2.x it loads, and there are bunch of plugins loaded that we've added.
In reply to Shawn Peters

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Ken Task -
Picture of Particularly helpful Moodlers


If you go to your site//admin/plugins.php?updatesonly=0&contribonly=1
You will see a listing of additional plugins
Just below the 'name' of the plugin, in gray, you will see the 'short name'
of the plugin.

Like Configurable Reports has block_configurable_reports.

Post a list back here so I can see them or PM me that list
and I'll run a moosh script (cli only and hard to run on Windows) that displays
info about the plugins ... like this:

Addon in que: block_configurable_reports
block_configurable_reports,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.10,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,https://moodle.org/plugins/download.php/22758/block_configurable_reports_moodle310_2020110300.zip

'SoS', Ken

In reply to Ken Task

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Shawn Peters -
I figured out a fix (see way below). It had nothing to do with plugins. Something screwy with the moodledata folder.
In reply to Shawn Peters

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Shawn Peters -
So I updated Moodle to 3.10.4 to see if that would fix things.
PHP v7.2.x has no issues. As soon as I load up PHP v7.3.x --- fails "Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting." Error again.

No idea what's so different in PHP v7.3 from v7.2
In reply to Shawn Peters

Re: PHP Upgrade - Fatal error: $CFG->dataroot

by Shawn Peters -
Well after too many days of banging my head on this one I think I have it resolved. I tired everything I could and re-assigned permissions and it would never work on PHP 7.3+.

Long story short I tried loading up a brand new Moodle install and it worked... What the heck....
So I created a brand new MoodleData folder and renamed the original/old one. Low and behold it worked... Serious.

On our live server I ended up moving all the 'moodledata' folders/files from our original folder to the new one and restarted the server. It's working just fine now. I have no idea what's actually different but something is screwy in the moodledata folder that PHP 7.3+ doesn't like. Espically that I moved the contents of the old folder into the new one.

So if someone else comes across this after upgrading PHP...
1) rename your 'moodledata' folder to 'moodledata-old'.
2) create a new 'moodledata' folder.
3) restart IIS.
4) launch browser and see if Moodle loads up. If it does continue on (if not, then you have other issues)
5) Move/copy the contents of 'moodledata-old' to the new 'moodledata' folder. (i did NOT overwrite existing files)

Hope this helps someone else out.

†Shawn