Skip to content

Add identity query capability to database handlers - #40

Draft
alexstandiford wants to merge 2 commits into
codex/db-timestamp-factory-compat-mainfrom
codex/db-identity-query
Draft

alexstandiford wants to merge 2 commits into
codex/db-timestamp-factory-compat-mainfrom
codex/db-identity-query

Conversation

@alexstandiford

@alexstandiford alexstandiford commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Expose the optional Datastore identity-query capability from identifiable database handlers. findIds() now validates its caller input before execution, resets query state, and selects only identity fields.

This PR is stacked on DB PR 41 for current-main timestamp compatibility and shared CI prerequisites. It also depends on phpnomad/datastore PR 11, specifically its final prerequisite commit fa0392a74d35bac3a0f1812d691d5a2163d80d68 on codex/ci-prerequisites-clean.

The DB package now declares phpnomad/event:^1.0 directly because DatabaseServiceProvider uses its runtime interface. Production keeps the released phpnomad/datastore:^2.0 constraint. CI checks out the PR11 branch and supplies it through a path repository with a runner-only version override.

Testing

  • composer validate --strict: passed
  • composer install --dry-run --no-interaction: lockfile is installable with nothing to change
  • vendor/bin/phpunit --colors=never: 41 tests, 144 assertions
  • vendor/bin/phpstan analyse --no-progress --level=9 lib/ tests/: no errors with the exact baseline inherited from PR41
  • Focused level-9 analysis of the changed trait and contract test: no errors
  • git diff --check: passed
  • PHP 7.4 syntax proof passed for the changed handler, focused test, and changed trait region
  • Mutation proof caught removal of query reset, replacement of identity projection with *, and removal of pre-query validation
  • A clean CI-style checkout installed Datastore commit fa0392a74d35bac3a0f1812d691d5a2163d80d68 through the path override, then passed PHPUnit and full level-9 PHPStan under PHP 8.2

The runtime proof used Datastore commit fa0392a74d35bac3a0f1812d691d5a2163d80d68 and this DB branch:

cd /home/alex/worktrees/phpnomad-wpdb-runtime-proof
docker compose -f docker-compose.identity-query.yml up -d
# Wait until /var/www/html/wp-includes/load.php exists in the wordpress service.
docker compose -f docker-compose.identity-query.yml exec -T wordpress php /opt/phpnomad/tests/Runtime/identity-query.php
docker compose -f docker-compose.identity-query.yml down

Observed output: PASS real wpdb + MySQL identity query

The harness exercised WordPress wpdb against MySQL 8.4, WordPress QueryStrategy, the concrete identifiable DB handler, grouped OR conditions, identity-only projection, limit 1, and offset 0. It also verified malformed groups, limit 0, and offset -1 execute no query.

Existing advisory

composer audit --locked --no-interaction reports CVE-2026-24765 in the existing PHPUnit 9.6.22 development dependency. The unchanged main commit 43551fc05d550c3daa6606c3d91fcddc0191b984 reports the same advisory. This PR does not introduce or change that dependency.

@alexstandiford
alexstandiford changed the base branch from main to codex/db-timestamp-factory-compat-main September 20, 2026 22:09
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