Skip to content

Resolve Classification Store key relations once per request - #2163

Open
lukmzig wants to merge 2 commits into
cs-store-improvementsfrom
1658-resolve-classification-store-key-relations-once-per-request
Open

lukmzig wants to merge 2 commits into
cs-store-improvementsfrom
1658-resolve-classification-store-key-relations-once-per-request

Conversation

@lukmzig

@lukmzig lukmzig commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Adds a request-scoped KeyRelationResolver so Classification Store key-to-group relations are loaded once per group instead of once per call.

  • Add an @internal KeyRelationResolver that memoises relations per group, returns clones, and is cleared by kernel.reset and by every Classification Store configuration write
  • Move the group and layout services, grid column resolver, data object adapter and the Classification Store filters onto the resolver
  • The adapter's getClassificationStoreKeysFromGroup() now returns keys in id ascending order instead of MySQL's unspecified order, so key order in object detail and search preview is deterministic
  • The grid column resolver keeps its InvalidArgumentException for a stale key id, so its error code is unchanged

Resolves pimcore/product-management#1658

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lukmzig lukmzig added this to the 2026.4.0 milestone Oct 27, 2026
@lukmzig lukmzig self-assigned this Oct 27, 2026
@lukmzig
lukmzig requested a balanced review from Copilot October 27, 2026 18:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The batched detail and preview reads lack adapter-level regression coverage for group-to-key mapping and preservation of resolver-provided relation order.

1 open issue
What changed in this PR

This PR centralizes Classification Store key-relation reads in a request-scoped resolver, reducing repeated database loads across Studio layouts, object data, grid columns, and filters.

Changes:

  • Adds per-group caching, batched loading, cloned results, and reset support.
  • Migrates consumers to the resolver and clears cached relations after configuration writes.
  • Adds resolver, filter, and invalidation tests; documents deterministic adapter ordering and internal interface changes.

Tests were not run in this review environment.

File Description
tests/​Unit/​Grid/​Column/​Resolver/​DataObject/​ClassificationStoreResolverTest.php Updates the resolver dependency mock.
tests/​Unit/​DataObject/​Data/​Adapter/​ClassificationStoreAdapterTest.php Wires the new adapter dependency.
tests/​Unit/​DataIndex/​Filter/​DataObject/​Classificationstore/​TimeFilterTest.php Tests resolved-key time ranges.
tests/​Unit/​DataIndex/​Filter/​DataObject/​Classificationstore/​StringFilterTest.php Tests string filtering and validation.
tests/​Unit/​DataIndex/​Filter/​DataObject/​Classificationstore/​SelectFilterTest.php Tests select filtering and validation.
tests/​Unit/​DataIndex/​Filter/​DataObject/​Classificationstore/​RGBAFilterTest.php Tests color channels and validation.
tests/​Unit/​DataIndex/​Filter/​DataObject/​Classificationstore/​InputQuantityValueFilterTest.php Tests value/unit filtering and validation.
tests/​Unit/​DataIndex/​Filter/​DataObject/​Classificationstore/​DateTimeFilterTest.php Tests datetime filtering without day rounding.
tests/​Unit/​DataIndex/​Filter/​DataObject/​Classificationstore/​DateFilterTest.php Tests date filtering with day rounding.
tests/​Unit/​DataIndex/​Filter/​DataObject/​Classificationstore/​BooleanFilterTest.php Tests boolean filtering and validation.
tests/​Unit/​DataIndex/​Filter/​ClassificationStoreFilterTestTrait.php Shares resolver mocks and string/array inputs.
tests/​Unit/​ClassificationStore/​Service/​KeyRelationResolverTest.php Tests caching, batching, cloning, ordering, and resets.
tests/​Unit/​ClassificationStore/​Service/​KeyGroupLayoutServiceTest.php Updates relation lookup expectations.
tests/​Unit/​ClassificationStore/​Service/​GroupServiceTest.php Uses keyed resolver results.
tests/​Unit/​ClassificationStore/​Service/​Configuration/​StoreServiceTest.php Tests cache clearing after store writes.
tests/​Unit/​ClassificationStore/​Service/​Configuration/​KeyServiceTest.php Tests cache clearing after key writes.
tests/​Unit/​ClassificationStore/​Service/​Configuration/​KeyGroupRelationServiceTest.php Tests invalidation after relation writes.
tests/​Unit/​ClassificationStore/​Service/​Configuration/​GroupServiceTest.php Tests invalidation after group writes.
tests/​Unit/​ClassificationStore/​Service/​Configuration/​CollectionServiceTest.php Tests invalidation after collection writes.
tests/​Unit/​ClassificationStore/​Service/​Configuration/​CollectionRelationServiceTest.php Tests invalidation after collection-relation writes.
src/​Grid/​Column/​Resolver/​DataObject/​ClassificationStoreResolver.php Uses cached relations while preserving stale-key errors.
src/​DataObject/​Data/​Adapter/​ClassificationStoreAdapter.php Batches detail/preview reads through the resolver.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​TimeFilter.php Uses cached key lookup.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​StringFilter.php Uses cached key lookup.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​SelectFilter.php Uses cached key lookup.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​RGBAFilter.php Uses cached key lookup.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​QuantityValueFilter.php Uses cached key lookup.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​NumberFilter.php Uses cached key lookup.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​InputQuantityValueFilter.php Uses cached key lookup.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​DateTimeFilter.php Uses cached key lookup.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​DateFilter.php Uses cached key lookup.
src/​DataIndex/​Filter/​DataObject/​Classificationstore/​BooleanFilter.php Uses cached key lookup.
src/​ClassificationStore/​Service/​KeyRelationResolverInterface.php Defines cached single-group and batch reads.
src/​ClassificationStore/​Service/​KeyRelationResolver.php Implements caching, cloning, and reset behavior.
src/​ClassificationStore/​Service/​KeyGroupLayoutService.php Resolves layout keys through the cache.
src/​ClassificationStore/​Service/​GroupService.php Uses cached group relations for layouts.
src/​ClassificationStore/​Service/​Configuration/​StoreService.php Clears relations after store writes.
src/​ClassificationStore/​Service/​Configuration/​KeyService.php Clears relations after key writes.
src/​ClassificationStore/​Service/​Configuration/​KeyGroupRelationService.php Clears relations after relation writes.
src/​ClassificationStore/​Service/​Configuration/​GroupService.php Clears relations after group writes.
src/​ClassificationStore/​Service/​Configuration/​CollectionService.php Clears relations after collection writes.
src/​ClassificationStore/​Service/​Configuration/​CollectionRelationService.php Clears relations after collection-relation writes.
src/​ClassificationStore/​Repository/​KeyGroupRelationRepositoryInterface.php Replaces individual lookups with batch loading.
src/​ClassificationStore/​Repository/​KeyGroupRelationRepository.php Loads multiple groups in ascending ID order.
doc/​02_Installation_and_Configuration/​05_Upgrade.md Documents caching, ordering, and interface changes.
config/​classification_store.yaml Registers the shared resolver service.

Review effort: Balanced

Comment thread src/DataObject/Data/Adapter/ClassificationStoreAdapter.php
…groupIds) in KeyGroupRelationRepository::getByGroupIds(); Added Codeception coverage for getDetailData() and getPreviewFieldData() asserting requested group ids, group-to-key mapping and resolver-provided relation order

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lukmzig
lukmzig requested a balanced review from Copilot October 27, 2026 19:14
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the shared Classification Store relation resolver change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@lukmzig
lukmzig marked this pull request as ready for review October 27, 2026 19:23
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.

2 participants