-
Notifications
You must be signed in to change notification settings - Fork 203
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
EZP-30427: Added support to paginate a list of drafts #2753
Conversation
* | ||
* @return \eZ\Publish\API\Repository\Values\Content\VersionInfo the drafts ({@link VersionInfo}) owned by the given user | ||
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException | ||
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php
Outdated
Show resolved
Hide resolved
93ffe24
to
f2742c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good.
I would do some API namespace cleanup, because eZ/Publish/API/Repository/Values/Content/
gets too crowded. Please change the API-related file and corresponding namespace structure as agreed during internal sync.
Other remarks:
eZ/Publish/API/Repository/Values/Content/ContentDraftListItem.php
Outdated
Show resolved
Hide resolved
eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php
Outdated
Show resolved
Hide resolved
7c8d0e2
to
70aaadb
Compare
6c786c3
to
3713898
Compare
3713898
to
d7269c5
Compare
class ContentDraftListItem implements ContentDraftListItemInterface | ||
{ | ||
/** | ||
* @var \eZ\Publish\API\Repository\Values\Content\VersionInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you wanted one line class member docs...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not about what I want :)
eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php
Outdated
Show resolved
Hide resolved
eZ/Publish/API/Repository/Values/Content/DraftList/Item/ContentDraftListItem.php
Outdated
Show resolved
Hide resolved
Co-Authored-By: Adam Wójs <adam.wojs@ez.no>
7404d5a
to
9ad846a
Compare
/** | ||
* Item of content drafts list which represents draft to which user has no access for. | ||
*/ | ||
class UnauthorizedContentDraftListItem implements ContentDraftListItemInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to push this logic to API consumer?
As in:
- Drafts are personal so at least in the past you usually had access to YOUR drafts.
- Even if there are cases where permissions won't let you, then I would expect it to behave like other API methods, aka filter out what you don't have access to. Otherwise paging in UI will have gaps, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ad 1 - You can pass user as an argument to loadContentDrafts(User $user = null)
so we have a case with a user's drafts which not belongs to you.
Ad 2 - To create "classic" pagination we need a total number of items. We can not use the search query to get it, because we have zeta components. This is a 3rd line issue and we do not have time to get rid of them. Also, it would be a BC break I think. This is why I used UnauthorizedContentDraftListItem
here and then in Admin UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be a BC break I think
This is for a new new API method, so there is no BC on it before it's released, that is when it will become harder to change all this ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass user as an argument to loadContentDrafts(User $user = null) so we have a case with a user's drafts which not belongs to you.
Good point 👍
But........ 😏 Then maybe you just made a very good argument for dropping this argument on the new API method in the first place. If people want to get drafts for other users they can either still use the old one or set current user to the user they want to get drafts for.
Dropping that argument seems like it will avoid a lot of the complexity introduced here.
And it will greatly improve DX for the primary use case: Getting drafts of current user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal was to keep all functionalities including the possibility to fetch drafts of another user even if it is a big number of them. Also, it will still be the issue when a user loses access to some of their drafts. I am against developing a feature which is buggy by design, even if it looks like a corner case.
We have a similar problem in content reverse relations where it is a common situation when a user has no access to some contents. And we have the plan to solve this issue in the same way (return the list with two kinds of items)
public $totalCount = 0; | ||
|
||
/** | ||
* @var \eZ\Publish\API\Repository\Values\Content\DraftList\ContentDraftListItemInterface[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the other question this can directly be VersionInfo instead perhaps.
* | ||
* @return \Doctrine\DBAL\Query\QueryBuilder | ||
*/ | ||
private function createVersionInfoFindQueryBuilder(): DoctrineQueryBuilder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can (by now) instead reuse ->queryBuilder-> createVersionInfoQueryBuilder()
which was just added as part of #2739
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT: Partly ignore this, unless we refactor it to work for your use case it won't atm (it expects to give current version or a provided version number only atm, and this one instead uses version table in from which is better in this case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA Approved with 6k drafts on eZ Platform EE v2.5.5 with both branches.
For the record, on Versions tab effect is not as amazingly smooth as on the Dashboard but also significant.
User does not have access message OK.
7.5
Added support to paginate a list of drafts.
Added additional arguments ($limit
and$offset
) toContentService::loadContentDrafts
Added new method
ContentService::countContentDrafts
to allow paginate content drafts list. This method returns the number of all drafts for the user, including those to which the user has no access.Instead of adding additional parameters to existing
ContentService::loadContentDrafts
this PR adds newContentService::loadContentDraftList
to allow paginate and filter content drafts list. New method returnContentDraftList
object. It can contain objects which implementsContentDraftListItemInterface
. Those can beUnauthorizedContentDraftListItem
orContentDraftListItem
Related PR: ezsystems/ezplatform-admin-ui#1071
TODO:
$ composer fix-cs
).