Repository navigation
Load the generated config.class.php: fixes a blank 500 on every page - #1546
Merged
Merged
Conversation
`class Config` is written by the installer into commons/config.class.php
and is the one .class.php file left anywhere in a deployed tree -- the
only class in FOG that is neither PSR-4 under src/ nor inside a plugin.
It was reached by the autoloader's recursive *.class.php scan of
BASEPATH. ADR 0035 retired that scan, and this was the single thing it
was still carrying, so `new Config()` in startInit() became
Uncaught Error: Class "Config" not found in commons/init.php:1383
on every page: a blank 500 in a browser, and installfog.sh's own
"Checking web server serves FOG" probe failing with 0 bytes of body.
Found by installing the merged tree, not by any run of the suite.
Required by name here, for the same reason fogpaths.php is required in
_loadPaths(): a generated file at a fixed path is pulled in, not found.
A missing one now names itself and says to re-run the installer, rather
than dying three lines later on a class nobody can locate.
WHY NOTHING CAUGHT IT, which is the more useful half. Every PHP test in
this suite constructs Initiator -- which only registers the autoloader
-- and stops before startInit(), because startInit() wants a database.
The entire boot tail therefore had no coverage at all.
tests/generated-config-is-loaded.test.sh closes that, without a
database, by driving commons/base.inc.php in a tree whose
config.class.php is a stub and asserting on WHICH error comes back: the
guard fires and names the file when it is absent, and the boot reaches
PDODB when it is present, which is the proof that Config resolved.
It boots through base.inc.php rather than management/index.php on
purpose. index.php reaches its includes as ../commons/..., which PHP
resolves against the real path, so a fixture that symlinks management/
runs against the repository's own commons/ and never sees the stub. The
first cut of this test did exactly that and passed for the wrong reason.
Mutation-verified four ways, all red: require deleted, require pointed
at a misspelled filename, require moved after the use, and the
is_readable guard inverted. The last three are the ones a textual check
for "require_once near new Config()" would have passed.
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the fix that was supposed to be in #1544 and wasn't. The merge queue snapshotted that branch before the second commit reached it, so #1544 merged only the
getClass()gate repair and left this behind.working-1.6is currently a blank 500 on every page for anyone who installs it.The bug
class Configis generated by the installer intocommons/config.class.php. It is the one.class.phpfile left anywhere in a deployed tree — the only class in FOG that is neither PSR-4 undersrc/nor inside a plugin — so it was being reached by the autoloader's recursive*.class.phpscan of BASEPATH. #1540 retired that scan, and this was the single thing it was still carrying:on every page. A blank white page in a browser, and
installfog.sh's own "Checking web server serves FOG" step failing withcurl exit 22, 0 bytes of body.Required by name now, the same way
fogpaths.phpalready is in_loadPaths()— a generated file at a fixed path gets pulled in, not found. A missing one names itself and says to re-run the installer, rather than dying three lines later on a class nobody can locate.config.class.phpwas the only casualty:findover an installed webroot returns exactly one.class.phpoutsidelib/plugins, and it has exactly one reference in the tree.Why nothing caught it
Every PHP test in the suite constructs
Initiator— which only registers the autoloader — and stops beforestartInit(), becausestartInit()wants a database. The whole boot tail had no coverage at all.tests/generated-config-is-loaded.test.shcloses that without a database, by drivingcommons/base.inc.phpin a tree whoseconfig.class.phpis a stub and asserting on which error comes back: the guard fires and names the file when it is absent, and the boot reachesPDODBwhen it is present — which is the proof thatConfigresolved.It boots through
base.inc.phprather thanmanagement/index.phpdeliberately.index.phpreaches its includes as../commons/..., which PHP resolves against the real path, so a fixture that symlinksmanagement/runs against the repository's owncommons/and never sees the stub. My first cut did exactly that and passed for the wrong reason.Mutation-verified four ways, all red: require deleted; require pointed at a misspelled filename; require moved after the use;
is_readableguard inverted. The last three are what a textual check for "require_oncenearnew Config()" would have waved through.Verified on top of current
working-1.6(c812eb352): suite 246/0, phpstan clean.