Repository navigation
fix(DatabaseManager): make setLogger() reach every driver - #273
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #273 +/- ##
============================================
+ Coverage 95.61% 95.66% +0.05%
- Complexity 2230 2234 +4
============================================
Files 142 142
Lines 6341 6351 +10
============================================
+ Hits 6063 6076 +13
+ Misses 278 275 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
test(DatabaseManager): cover setLogger() with factory, added drivers and databases, clones, reconnect and transactions A logger set explicitly now takes precedence over the LoggerFactory for existing and future drivers, and is passed to drivers registered via addDriver() and addDatabase(). Drivers cloned by Database::withoutCache() are not tracked by the manager and keep the logger they had when cloned. Refs cycle/orm#60 Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
roxblnfk
force-pushed
the
test/orm-60-set-logger
branch
from
October 4, 2026 17:32
23a64ec to
a00cf3e
Compare
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 was changed
DatabaseManager::setLogger()now reaches every driver it knows about: drivers created before or after the call, drivers registered viaaddDriver(), and the drivers of databases registered viaaddDatabase().setLogger()now takes precedence over theLoggerFactory, for existing and future drivers. Before this, every driver created after the call got the factory's logger and the explicit one was ignored. This affected every Spiral application, becausespiral/cycle-bridgealways passes aLoggerFactory. The factory is still used while no logger is set.NullLoggeris now passed to drivers as is. ANullLoggerreturned by the factory is still skipped, so drivers without a logger don't build the log context for every query.Why?
The scenarios where the logger was lost are covered by
DatabaseManagerLoggerTest, 21 cases. Before this fix, 7 of them failed on 2.x.Review notes
Database::withoutCache()clones its drivers, and the manager does not track those clones. A clone made beforesetLogger()keeps the logger it had when it was cloned. Tracking clones would need a shared logger holder between a driver and its clones, which is out of scope here. The limitation is documented onsetLogger()and pinned by a test.testDatabaseManagerWithLoggerAndWithLoggerFactoryShouldReturnLoggerFromFactoryasserted the old priority (the factory wins over an explicit logger). It is replaced by the opposite assertion, plus a test that the factory is still used when no logger is set.Checklist
DBAL->setLogger()orm#60phpunit --testsuite Unitandphpunit --group driver-sqlitepass locally