Throw xPDOException when ContainerInterface lacks required 'config' entry#279
Merged
opengeek merged 1 commit intomodxcms:3.xfrom Apr 7, 2026
Merged
Conversation
…ntry Previously, passing a PSR-11 container without a 'config' entry to xPDO caused initConfig() to silently fall back to a minimal default config array, hiding the broken API contract from the caller. Now an explicit xPDOException is thrown, making the required contract clear. Closes modxcms#269.
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.
What changed and why
xPDO::initConfig()silently fell back to a minimal default config when a PSR-11ContainerInterfacewas passed without a'config'entry, hiding the broken API contract from callers. The fix adds an explicitxPDOExceptionin that case, making the required contract clear at construction time rather than producing mysterious runtime failures.Closes #269.
Files and methods changed
src/xPDO/xPDO.php—initConfig(): addelsebranch throwingxPDOExceptionwhen container lacks'config'entry.test/xPDO/Test/xPDOPsr11InitTest.php— new test file (2 test methods).test/sqlite.phpunit.xml,test/mysql.phpunit.xml,test/pgsql.phpunit.xml,test/complete.phpunit.xml— new test file registered in Complete testsuite.Cross-driver impact
Universal.
initConfig()runs before any driver-specific code. All four driver configs updated.Test coverage
New:
test/xPDO/Test/xPDOPsr11InitTest.php— 2 tests (regression + positive path).Full suite (sqlite): Tests: 432, Assertions: 598, Skipped: 1 — zero failures.
Breaking change assessment
Behavior change for callers passing a
ContainerInterfacewithout a'config'entry — they now receive an explicit exception instead of silent misconfiguration. Callers using the PSR-11 path correctly are unaffected. This is an intentional correction of a broken API contract, not introduced by design.AI Disclosure
This fix was developed using an AI-assisted workflow. AI agents (Claude) wrote tests, code, and performed initial code review under the direction of the project maintainer (@opengeek), who reviewed the final diff, validated the approach, and takes responsibility for the submission.
Contributors
No external contributor. Follow-on from PR #265 (PSR-3 logger, merged 2026-03-08).