Skip to content

fix(settings): guard canastaLoadConfigYaml against null $wgSettings#181

Merged
yaronkoren merged 1 commit into
masterfrom
fix-167-yaml-loader-guard
Jun 28, 2026
Merged

fix(settings): guard canastaLoadConfigYaml against null $wgSettings#181
yaronkoren merged 1 commit into
masterfrom
fix-167-yaml-loader-guard

Conversation

@cicalese

Copy link
Copy Markdown
Contributor

Problem

Running PHPUnit unit tests on a Canasta-built MediaWiki (composer phpunit:unit, core or extension) fatals during MediaWiki's extension-discovery step:

PHP Fatal error:  Uncaught Error: Call to a member function loadFile() on null
  in /var/www/mediawiki/w/CanastaDefaultSettings.php:173

MediaWiki's unit-test runner avoids initialising Setup.php, but still enumerates installed extensions to find their tests by spawning tests/phpunit/getPHPUnitExtensionsAndSkins.php, which sources LocalSettings.php. That requires CanastaDefaultSettings.php, which calls canastaLoadConfigYaml()$wgSettings->loadFile(). Since $wgSettings is normally initialised by Setup.php (bypassed here), it is null and the call fatals.

Fix

Return early from canastaLoadConfigYaml when $wgSettings === null — config-YAML loading is meaningless on that non-request code path. No effect on normal request bootstrap, where Setup.php has 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

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
@github-actions

Copy link
Copy Markdown

🐳 The image based on 2fc137d4 commit has been built with 1.43.8-20260628-181 tag as ghcr.io/canastawiki/canasta-base:1.43.8-20260628-181

@yaronkoren yaronkoren merged commit be090e6 into master Jun 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

canastaLoadConfigYaml fatals during PHPUnit unit-test extension discovery

2 participants