Core: Pagination for subresources does not work

Created on 8 Apr 2019  路  3Comments  路  Source: api-platform/core

Gives Undefined index: collection_operation_name.
Bug is in recent master and in 2.4 version. v2.3.6 works fine.

in src/Hydra/Serializer/PartialCollectionViewNormalizer.php if you replace line

$isPaginatedWithCursor = $paginated && null !== $metadata && null !== $cursorPaginationAttribute = $metadata->getCollectionOperationAttribute($context['collection_operation_name'], 'pagination_via_cursor', null, true);

with

$isPaginatedWithCursor = $paginated && null !== $metadata && null !== $cursorPaginationAttribute = $metadata->getCollectionOperationAttribute($context['collection_operation_name'] ?? $context['subresource_operation_name'], 'pagination_via_cursor', null, true);

it starts to work, though there are some other pagination bugs since 2.4, which I will post separately.

bug

Most helpful comment

thanks!

All 3 comments

this fix looks correct, may you open a PR?

@soyuka I created the PR. I was wrong, looks like the bug is only in master currently.

thanks!

Was this page helpful?
0 / 5 - 0 ratings