Conversation
…thods (7.0)
Version 7.0 completes the refactoring started in 6.0 and adds the
observability features:
Breaking changes:
- Remove the query methods deprecated since 6.0 (getIterator, getScalar,
getAllFields, execute, executeAndGetId) from DbDriverInterface, the
PDO/OCI8 drivers and DatabaseRouter. DatabaseExecutor is now the
single API for executing queries and commands.
New features:
- Generic event mechanism on DatabaseExecutor
(DatabaseEventObserverInterface, addObserver/removeObserver) firing
BEFORE/AFTER_QUERY and BEFORE/AFTER_EXECUTE events, with no overhead
when no observer is attached.
- Journal package records INSERT, UPDATE and DELETE statements with the
row values before and after each operation:
- JournalRecorder watches all tables or a specific set, with
configurable primary keys
- JournalRestorer replays the journal in reverse to restore the
previous database state (functional test setUp/tearDown)
- Optional strict mode throws JournalException on statements that
cannot be journaled/restored instead of skipping them silently
Infrastructure:
- Pin the SQL Server image to 2022-latest in docker-compose.yml and CI:
the 2025 image (current 'latest') crashes on startup on hybrid CPUs
(Intel P/E-cores) with a topology assert. Rename the compose service
from mssql to sqlserver (matching CI), use MSSQL_SA_PASSWORD instead
of the deprecated SA_PASSWORD, and fix wait-for-db.sh reporting the
database as up when the health check timed out.
Includes tests, documentation (docs/observers.md, docs/journal.md,
removal notes across existing docs) and CHANGELOG-7.0.md.
Cloudflare D1 is SQLite compatible but reachable only over HTTPS, so it has
no PDO driver. DbD1Driver implements DbDriverInterface directly on top of the
D1 REST API, following the structure of the existing non-PDO driver
(DbOci8Driver): prepareStatement builds the request, executeCursor performs
the POST and D1Iterator wraps the returned rows.
d1://{account_id}:{api_token}@api.cloudflare.com/{database_id}
Details worth noting:
- Named parameters are rewritten to the positional "?" placeholders the API
expects, handling repeated parameters, quoted literals and "::" casts.
- executeAndGetInsertedId() reads meta.last_row_id from the response.
"select last_insert_rowid()" would run as a separate HTTP request on a
different connection and always answer 0.
- Transactions throw NotAvailableException: the API rejects BEGIN/COMMIT
because every request is already committed atomically on its own.
- The Sessions API is only available through the Workers binding, so the
driver cannot provide sequential consistency when read replication is
enabled. isServedByPrimary()/getServedByRegion() expose what D1 reports.
The driver works with any PSR-18 client and falls back to byjg/webrequest.
tests/D1DriverTest.php covers it through a recording transport double, so it
runs in CI without credentials; testsdb/D1Test.php runs against a real
database and skips unless D1_ACCOUNT_ID, D1_DATABASE_ID and D1_API_TOKEN are
set. Both suites were verified against a live D1 database.
Dependencies byjg/uri, byjg/anydataset, byjg/cache-engine and byjg/webrequest
move to ^7.0.
Widen the PHP constraint to ">=8.3 <8.7"; the previous "<8.6" is exclusive and excluded PHP 8.6. Bump byjg/* dependencies to ^7.0. While 7.0 is unreleased these resolve to 7.0.x-dev from each component's 7.0 branch, via minimum-stability dev with prefer-stable. Pin PHPUnit to ^12.5 and move Psalm to tools/psalm/composer.json. Psalm enumerates supported PHP versions and no release lists 8.6, so as a require-dev it made "composer install" fail on the 8.6 build before any test ran. "composer psalm" bootstraps the tool and runs it. CI: add PHP 8.6 to the matrix; the Psalm job runs on 8.5. Housekeeping: rename phpunit.xml.dist to phpunit.xml, carry the 6.x changelogs onto this branch, and update CHANGELOG-7.0.md.
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.
Summary
Major release completing the refactoring started in 6.0. See
CHANGELOG-7.0.mdfor the full changelog.Breaking changes
getIterator,getScalar,getAllFields,execute,executeAndGetId) fromDbDriverInterface, the PDO/OCI8 drivers andDatabaseRouter.DatabaseExecutoris now the single API for queries and commands. Docs updated accordingly (docs/deprecated-features.mdis now the migration guide).Executor Observers
DatabaseEventObserverInterface, attachable withDatabaseExecutor::addObserver()/removeObserver()BEFORE_QUERY,AFTER_QUERY,BEFORE_EXECUTE,AFTER_EXECUTE, each carrying aDatabaseEventwith theSqlStatement, the executor and the resultJournal (record and restore DML changes)
JournalRecorder::forAllTables()/::forTables(...)records INSERT/UPDATE/DELETE with row values before and after each operation; configurable primary keysJournalRestorerreplays the journal in reverse — designed for functional test setUp/tearDownJournalExceptionon statements that cannot be journaled/restored (unparseable DML is blocked before execution) instead of skipping silentlyInfrastructure
2022-latest(compose + CI): the 2025 image crashes on startup on hybrid CPUs (Intel P/E-cores) with a topology assert; compose service renamedmssql→sqlserverto match CI;MSSQL_SA_PASSWORD;wait-for-db.shno longer reports success on health-check timeoutTesting
Supersedes #35.