fix(settings): guard canastaLoadConfigYaml against null $wgSettings#181
Merged
Conversation
MediaWiki's PHPUnit unit-test runner enumerates installed extensions by spawning tests/phpunit/getPHPUnitExtensionsAndSkins.php, which sources LocalSettings.php without first initialising Setup.php. $wgSettings is therefore null when CanastaDefaultSettings.php calls canastaLoadConfigYaml, and the $wgSettings->loadFile() call fatals with 'Call to a member function loadFile() on null', breaking 'composer phpunit:unit'. Return early when $wgSettings is null so config-YAML loading is skipped on that non-request code path. Closes #167
|
🐳 The image based on 2fc137d4 commit has been built with |
yaronkoren
approved these changes
Jun 28, 2026
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.
Problem
Running PHPUnit unit tests on a Canasta-built MediaWiki (
composer phpunit:unit, core or extension) fatals during MediaWiki's extension-discovery step:MediaWiki's unit-test runner avoids initialising
Setup.php, but still enumerates installed extensions to find their tests by spawningtests/phpunit/getPHPUnitExtensionsAndSkins.php, which sourcesLocalSettings.php. That requiresCanastaDefaultSettings.php, which callscanastaLoadConfigYaml()→$wgSettings->loadFile(). Since$wgSettingsis normally initialised bySetup.php(bypassed here), it isnulland the call fatals.Fix
Return early from
canastaLoadConfigYamlwhen$wgSettings === null— config-YAML loading is meaningless on that non-request code path. No effect on normal request bootstrap, whereSetup.phphas already created$wgSettings.PHP lint clean; existing test suite passes (29). No test added — the repo has no PHP unit-test harness yet (tracked in #130 / #46).
Closes #167