Skip to content
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-6773: Bookmarks for non accessible contents cause exception #408

Open
wants to merge 13 commits into
base: 1.3
Choose a base branch
from

Conversation

vidarl
Copy link
Member

@vidarl vidarl commented May 24, 2024

Question Answer
JIRA issue IBX-6773
Type bug
Target Ibexa version v3.3
BC breaks yes

If user bookmark some location which he later looses access too, then the bookmark list in admin-ui fails with an exception.
Simply fixing BookmarkService::loadBookmarks() would be easy. The problem is to implement countUserBookmarks() in persistence layer and having it taking into account user permissions so that BC would be kept.

Talked with Adam on how to solve this without breaking BC and he suggested implementing it using filtering

The Bookmark filter will only work with location filtering (LocationService::find()), not with content (ContentService::find())

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (master for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ezsystems/engineering-team).

@vidarl vidarl marked this pull request as draft May 24, 2024 14:08
@vidarl vidarl force-pushed the IBX-6773_Bookmarks_for_non-accessible_contents_cause_exception branch 2 times, most recently from a15afa0 to 7246b2e Compare May 30, 2024 12:23
@vidarl vidarl force-pushed the IBX-6773_Bookmarks_for_non-accessible_contents_cause_exception branch from e2d1c9a to ddca556 Compare June 6, 2024 13:42
@vidarl vidarl marked this pull request as ready for review June 6, 2024 13:43
@vidarl vidarl requested a review from a team June 6, 2024 13:43
vidarl and others added 6 commits June 25, 2024 13:44
@vidarl vidarl requested review from Steveb-p and ViniTou June 26, 2024 13:16
@Steveb-p Steveb-p changed the title Ibx-6773 Bookmarks for non accessible contents cause exception IBX-6773: Bookmarks for non accessible contents cause exception Jun 27, 2024
Comment on lines 1990 to 1996
$expectedIdsAfter = array_map(static function (Location $item) use ($demoDesignLocationId, $contactUsLocationId) {
if ($item->id === $demoDesignLocationId) {
return $contactUsLocationId;
}

return $item->id;
}, $beforeSwap->items);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this mapping necessary? In particular, why is there a special case for $demoDesignLocationId + $contactUsLocationId?

Copy link
Member Author

@vidarl vidarl Jun 27, 2024

Choose a reason for hiding this comment

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

The mapping is no longer needed. In first version of PR, I did not implement SortClause\BookmarkId, so order of the result needed to be normalized.
I will revert the mapping.

I think the test is better when adding $contactUsLocation. In original test we test the edge case where two bookmarked locations are swapped... In my version of the test, only one of the locations that are swapped are bookmarked.

Edit: Fixed cut&paste error that made the second paragraph meaningless

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 8483861

ok?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Steveb-p @ViniTou : Could you have a second look on this please?

Copy link
Member Author

@vidarl vidarl Aug 29, 2024

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

eZ/Publish/API/Repository/Tests/LocationServiceTest.php Outdated Show resolved Hide resolved
eZ/Publish/Core/Repository/BookmarkService.php Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Jun 27, 2024

@vidarl vidarl requested a review from Steveb-p June 27, 2024 11:11
@vidarl vidarl requested a review from Steveb-p October 3, 2024 13:42
eZ/Publish/Core/Repository/BookmarkService.php Outdated Show resolved Hide resolved
Copy link
Member

@konradoboza konradoboza left a comment

Choose a reason for hiding this comment

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

Please make sure the deprecated methods get removed on merging this up to main.

Co-authored-by: Paweł Niedzielski <[email protected]>
Co-authored-by: Konrad Oboza <[email protected]>
Copy link

sonarcloud bot commented Nov 8, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

7 participants