-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IBX-8470: Upgraded Pagerfanta to v3 for Symfony 6 #462
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alongosz
force-pushed
the
ibx-8470-symfony-6
branch
from
December 11, 2024 15:46
682d6d7
to
be8e99d
Compare
…mproved code quality
alongosz
force-pushed
the
ibx-8470-pagerfanta
branch
from
December 11, 2024 22:11
c59072b
to
7d97e72
Compare
ViniTou
approved these changes
Dec 12, 2024
Co-authored-by: Dawid Parafiński <dawid.parafinski@ibexa.co>
konradoboza
approved these changes
Dec 13, 2024
tests/lib/Pagination/BaseContentSearchResultAdapterTestCase.php
Outdated
Show resolved
Hide resolved
Quality Gate failedFailed conditions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Warning
This is a PR targeting another PR #447
Related PRs:
Description:
This PR targets #447 and should be merged into that when/if approved.
We're forced to upgrade Pagerfanta in core to v3 as
babdev/pagerfanta-bundle
required by AdminUI supports v3+ for Symfony 6+.There seem to be not a lot of breaking changes, but Pagerfanta v3 adds PHPStan templated type hints and since we extend adapters, create custom ones, and rely inside of those adapters on SearchService value objects, we needed to add/extend/implement those templates in core as well.
I. There are currently at least 2 key design flaws in core:
interface \Ibexa\Core\Pagination\Pagerfanta\SearchResultAdapter extends \Pagerfanta\Adapter\AdapterInterface
While it was convenient to avoid issues when there was no native support for intersection types, now it created an issue as PF
AdapterInterface
became a template, therefore CoreSearchResultAdapter
needed to be one as well, even though none of the methods rely on typeT
.ContentSearchAdapter
andLocationSearchAdapter
extendedContentSearchHitAdapter
andLocationSearchHitAdapter
respectively.Consider, for example, that:
ContentSearchAdapter::getSlice()
returnswhile
ContentSearchHitAdapter::getSlice()
returnsSearchHit
andContent
are not covariant with respect to each other (their common base isValueObject
) thereforegetSlice()
returning iterableContent
list cannot override the one returningSearchHit
list. It worked due to lack of strict types prior Pagerfanta v3.To resolve that second design flaw I've changed
*SearchAdapter
s to inject relevant*SearchHitAdapter
s as a composition rather than inherit them. From usage standpoint there's no behavior BC break.II. SearchService value object templates.
Given our adapters need to extend a templated AdapterInterface, the following SearchService contracts ValueObjects are now also templates:
SearchHit
due to$valueObject
property. This can beContenInfo
,Content
,Location
, but also their persistence layer counterparts. Therefore declared it as@template-covariant T of \Ibexa\Contracts\Core\Repository\Values\ValueObject
. We might want to go into the direction ofobject
there in the future, to extend cearch capabilities.SearchResult
as it contains a list ofSearchHit
instances.II. Language Filtering types for Search and Filtering.
Not really a must, but since it popped up after the other changes, it might be a good time to introduce PHPStan array shapes:
TSearchLanguageFilter
andTFilteringLanguageFilter
as the variable is often named the same while expecting different inputs.III. Total count
Pagerfanta v3 defines total count as
int<0, max>
, so everything relying on that needed to be aligned. UnfortunatelyFixedSearchResultHitAdapter
returns in case of null-1
. That needs to be changed to null value, but it needs to be done carefully and as a follow-up. Therefore added that to the Pagerfanta-dedicated baseline.IV. Pagerfanta-dedicated baseline
There's still a lot to refactor there and it could probably take a long time. Therefore at some point of endless refactoring I've decided after talking with @Steveb-p to add Pagerfanta-dedicated baseline and resolve as a follow-up later. Some of those issues are probably trivial, so if you have quick ready to apply solution for any of those, feel free to suggest it.
V. Code duplication
No idea how to resolve it ATM. While the code is the same, it operates on different PHPStan templated types, so effectively needs to be duplicated. Unless there's a better way to shape it?
Key changes:
Content\Search\SearchResult
int<0, max>
)