Skip to content

Expose WordPress query sources and pinned builders - #43

Draft
alexstandiford wants to merge 1 commit into
codex/real-wpdb-query-contract-testsfrom
codex/wordpress-query-boundary
Draft

alexstandiford wants to merge 1 commit into
codex/real-wpdb-query-contract-testsfrom
codex/wordpress-query-boundary

Conversation

@alexstandiford

@alexstandiford alexstandiford commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Scope

This PR stacks on PR 41. It adds the WordPress query-boundary prerequisite for coordinated database work.

QueryBuilder now implements HasQueryTables and reports the exact root table followed by every join table in query order. Full resets, clause resets, successful builds, root replacement, and builder reuse keep the metadata aligned with the SQL. The existing dynamic join state is now a declared property and resets with the rest of the query.

QueryBuilder and ClauseBuilder accept an optional wpdb object. An explicit object owns preparation for that builder. Zero-argument construction still reads the WordPress global, including subclasses whose constructors do not call the parent constructor.

Transaction ownership and coordinated execution remain in later slices.

Review dependency

The Composer constraint temporarily aliases phpnomad/db dev-release/2.2 as 2.2.x-dev. The lock points at 17fb84703d260a66de874704ae37cf924b9d8c2b, which contains HasQueryTables. The review repository uses public HTTPS, so CI can install the branch without SSH keys. Replace the alias with a released constraint after the database release exists.

Verification

Unit suite:

vendor/bin/phpunit -c phpunit.xml --colors=never

Result: 78 tests, 139 assertions.

Required real database suite:

WORDPRESS_ROOT=<official-wordpress-6.8.3-root> MYSQL_HOST=127.0.0.1 MYSQL_PORT=<mysql-port> MYSQL_USER=root MYSQL_PASSWORD=<test-fixture-password> MYSQL_DATABASE=phpnomad_wordpress_query_boundary vendor/bin/phpunit -c phpunit-integration.xml --colors=never --fail-on-skipped

Result: 60 tests, 116 assertions, with no failures, errors, or skips.

The integration proof uses official WordPress 6.8.3 at ba9e7f97f08a7fbb88fbfa35641bcc230500b37a and MySQL 8.0.45. It replaces global $wpdb with a throwing sentinel while both builders prepare through the injected real wpdb. The resulting joined query runs against MySQL. The same case proves exact root and join object identity, join removal, successful-build reset, and reuse without stale join SQL.

Composer validation passes. Its existing package-version warning remains. GitHub CI installs the temporary dependency over public HTTPS and passes.

Architecture records

@alexstandiford
alexstandiford force-pushed the codex/wordpress-query-boundary branch from e8df634 to 496e357 Compare September 20, 2026 23:10
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.

1 participant