IBX-6773: Fixed loading Bookmarks for non-accessible content items#476
IBX-6773: Fixed loading Bookmarks for non-accessible content items#476
Conversation
bdac332 to
9164daa
Compare
|
9164daa to
ec96060
Compare
konradoboza
left a comment
There was a problem hiding this comment.
Did you make sure none of the deprecated classes are still in use?
|
@konradoboza : FYI : Had to add related PR : ibexa/admin-ui#1835 |
| $this->assertEquals($contactUsLocationId, $afterSwap->items[0]->id); | ||
| $this->assertEquals($beforeSwap->items[1]->id, $afterSwap->items[1]->id); |
There was a problem hiding this comment.
Why this change? It's not clear at first glance.
There was a problem hiding this comment.
@konradoboza
The testcase initially tests swapping two locations that are both bookmarked.
I modified the test to check behavior when 1 location is bookmarked and the other is not
…n - Added more Strict typing
…tion/BookmarkQueryBuilderTest.php Co-authored-by: Konrad Oboza <konrad.oboza@ibexa.co>
Co-authored-by: Konrad Oboza <konrad.oboza@ibexa.co>
…cationService::count()
…cationService::count()
… and LocationService::count()
Co-authored-by: Konrad Oboza <konrad.oboza@ibexa.co>
5343730 to
6c862de
Compare
Adjusted tests accoringly to latest commits
This reverts commit 2e5d7c7.
| /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\IsBookmarked $criterion */ | ||
| $isBookmarked = $criterion->value; | ||
| $userId = $criterion->userId ?? $this->permissionResolver->getCurrentUserReference()->getUserId(); | ||
|
|
There was a problem hiding this comment.
@alongosz
There is one problem with this queryBuilder.. In Bookmark table, we store node_id, so we need to join with ezcontentobject_tree. That is no problem if LocationService::find() is used.
However, ATM it won't work with Content filtering (ContentService::find() as that table is already join in that case
I don't see a safe way to detect in the queryBuilder if we are either in Content or Location context..
I have a proposal below using $queryBuilder->getExistingTableAliasJoinCondition but not sure if it is really safe. It checks if alias "location" is joined at that time or not. But not sure if order is deterministic and if this good enough, but not sure if there is any other alternative ?
The other option is somehow to state that this filter can only use with Location ?
| $isContentQuery = $queryBuilder->getExistingTableAliasJoinCondition('location') === null; | |
| if ($isContentQuery) { | |
| $connection = $queryBuilder->getConnection(); | |
| $subQb = $connection->createQueryBuilder(); | |
| $paramName = $queryBuilder->createNamedParameter( | |
| $userId, | |
| ParameterType::INTEGER | |
| ); | |
| $subQuerySql = $subQb | |
| ->select('1') | |
| ->from(Gateway::CONTENT_TREE_TABLE, 'l') | |
| ->innerJoin('l', DoctrineDatabase::TABLE_BOOKMARKS, 'b', 'l.node_id = b.node_id') | |
| ->where('l.contentobject_id = content.id') | |
| ->andWhere("b.user_id = $paramName") | |
| ->getSQL(); | |
| return $isBookmarked | |
| ? "EXISTS ($subQuerySql)" | |
| : "NOT EXISTS ($subQuerySql)"; | |
| } |
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
| namespace Ibexa\Tests\Integration\Core\Repository\Filtering; |
There was a problem hiding this comment.
@alongosz : I created a integration test for IsBookmarked. Didn't actually find any other similar integration tests for other criterieons, so added it here. Not sure if there is a better place to put it ?
|



v4.6Related PRs:
loadBookmarkscall with Repository filtering requirements admin-ui#1835Description:
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 implementcountUserBookmarks()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())This is a port of ezsystems/ezplatform-kernel#408 which was not approved and merge in time before 3.3 went EOL.
For QA:
Read ticket for info on how to reproduce
Documentation:
Documentation for the new filter needs to be made, indeed