Skip to content

[fix] inverse ternary operator statements #7085

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: 3.4
Choose a base branch
from

Conversation

pierre-kubica
Copy link

Just a simple fix...

It could explain this maybe: api-platform/api-platform#2434

@@ -79,7 +79,7 @@ public function getResourceObjectType(ResourceMetadataCollection $resourceMetada

if ('item_query' === $operationName || 'collection_query' === $operationName) {
// Test if the collection/item has different groups
if ($resourceMetadataCollection->getOperation($operation instanceof CollectionOperationInterface ? 'item_query' : 'collection_query')->getNormalizationContext() !== $operation->getNormalizationContext()) {
if ($resourceMetadataCollection->getOperation($operation instanceof CollectionOperationInterface ? 'collection_query' : 'item_query')->getNormalizationContext() !== $operation->getNormalizationContext()) {
Copy link
Member

Choose a reason for hiding this comment

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

this is wanted see above comment

Copy link
Author

Choose a reason for hiding this comment

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

You mean this "Test if the collection/item has different groups" ? It's not very explicit.

Sorry for not explained with more details but I thought it was obvious to understand. If you don't inverse as I suggest you'll need to allow QueryCollection operation if you only set Query operation. Same for the inverse (Query operation only will need QueryCollection operation). That's because the ternary operator is wrong.

It's history for me as I fixed it locally but I get the message 'Operation "item_query" not found for resource "Project"' from #api-platform/api-platform#2434 which was my case.

Copy link
Member

Choose a reason for hiding this comment

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

In API Platform if a collection operation, an item operation must exist. So probably that the correct fix for this would be to always create an empty item_query if we couldn't find any here.

Copy link

stale bot commented Jun 21, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 21, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants