Skip to content

Reset joined-inheritance result mapping when SQL filters change - #12720

Open
akasakariko wants to merge 1 commit into
doctrine:2.20.xfrom
akasakariko:fix/12530-index-by-filter
Open

akasakariko wants to merge 1 commit into
doctrine:2.20.xfrom
akasakariko:fix/12530-index-by-filter

Conversation

@akasakariko

Copy link
Copy Markdown

Summary

Fixes #12530

When a SQL filter changes, JoinedSubclassPersister rebuilds its SELECT columns but retains the previous result-set mapping
For inherited fields, this can leave multiple column aliases in the mapping, causing indexBy to select an alias absent from the current result and hydrate a null collection key

  • Start a fresh result-set mapping when rebuilding the SELECT column list
  • Preserve filter cache invalidation and public APIs
  • Add one regression test using existing Company fixtures, covering an eager collection indexed by an inherited field before and after enabling a filter
Q A
BC Break no
Target 2.20.x

Local verification

PHP 8.3 with SQLite, using Docker through Colima

  • Reproduced the reporter's failure on ORM 2.20.13, then verified the supplied reproducer loads both children with this patch
  • vendor/bin/phpunit --filter testIndexedEagerCollectionWithFilterOnCTI fails before the fix with Undefined array key "id_2" and passes afterward
  • php -d memory_limit=1G vendor/bin/phpunit -c ci/github/phpunit/pdo_sqlite.xml — 3971 tests, 13929 assertions, no failures or errors, 78 skipped and 2 incomplete
  • vendor/bin/phpunit --filter 'SwitchContextWithFilter|SQLFilterTest|JoinedSubclassPersister|ClassTableInheritance' with DBAL 2.13.9 — 77 tests and 292 assertions passed
  • The same focused suite with DBAL 3.10.6, -c ci/github/phpunit/sqlite3.xml and ORM_PROXY_IMPLEMENTATION=lazy-ghost — 77 tests and 292 assertions passed
  • vendor/bin/phpcs --parallel=1 src/Persisters/Entity/JoinedSubclassPersister.php tests/Tests/ORM/Functional/SQLFilterTest.php — passed
  • PHP syntax checks for both changed files, composer validate --strict, composer check-platform-reqs and git diff --check — passed

Existing static-analysis failures

  • vendor/bin/phpstan analyse --no-progress --memory-limit=1G reports one Symfony 7.4 deprecation in ApplicationCompatibility.php:27
  • vendor/bin/phpstan analyse -c phpstan-dbal2.neon --no-progress --memory-limit=1G reports 22 diagnostics with DBAL 2
  • Both configurations were rerun with the unmodified production file from the base commit and produced identical diagnostics before and after this change
  • No unrelated fixes or suppressions are included

The full upstream PHP and database matrix was not run locally

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