The 'fix' provided by using the cfg.php tool in admin/cli/ - so credit goes to whomever thought of/wrote/maintains that script.
I now do this on every server:
cd code/admin/cli/
php cfg.php > allsettings.txt
The hardest part of 'fixing' something in moodle config.php is learning the 'variablename'. If one kinda knows what one is looking for, this works:
php cfg.php |grep additional
Pulls any/all settings that have 'additional' in 'short name'.
Above command displays:
additionalhtmlhead
additionalhtmltopofbody
additionalhtmlfooter
Above from a site that has no additional html inserted.
To 'blank':
$CFG->additionalhtmlhead='';
in config.php file. No reboot nor restart required, just access with browser.
In some cases, such as OP's problem with WSOD, brings site back into view and enables admin to find/edit/change the errant setting.
After the addition to config.php has done it's job, can comment it out by putting // in front of that line, for the next time one messes up!
Once again, it does illustrate that having CLI access to a Moodle server is a very big plus in administering. That's a biggy in choosing where/how to host a Moodle, IMHO!
'SoS', Ken