-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IBX-6773: Bookmarks for non-accessible contents cause exception
- Loading branch information
Showing
9 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
eZ/Publish/API/Repository/Values/Content/Query/Criterion/Bookmark.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace eZ\Publish\API\Repository\Values\Content\Query\Criterion; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\Query\Criterion; | ||
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator\Specifications; | ||
use eZ\Publish\SPI\Repository\Values\Filter\FilteringCriterion; | ||
|
||
/** | ||
* A criterion that matches content based on its parent location id. | ||
* | ||
* Own location id is done using {@see LocationId} | ||
* | ||
* Supported operators: | ||
* - IN: matches against a list of location ids | ||
* - EQ: matches against a unique location id | ||
*/ | ||
class Bookmark extends Criterion implements FilteringCriterion | ||
{ | ||
/** | ||
* Creates a new ParentLocationId criterion. | ||
* | ||
* @param int|int[] $value One or more locationId parent locations must be matched against | ||
* | ||
* @throws \InvalidArgumentException if a non numeric id is given | ||
* @throws \InvalidArgumentException if the value type doesn't match the operator | ||
*/ | ||
public function __construct($value) | ||
{ | ||
parent::__construct(null, null, $value); | ||
} | ||
|
||
public function getSpecifications(): array | ||
{ | ||
return [ | ||
new Specifications(Operator::EQ, Specifications::FORMAT_SINGLE, Specifications::TYPE_INTEGER), | ||
]; | ||
} | ||
} |
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
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
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
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
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
47 changes: 47 additions & 0 deletions
47
...sh/Core/Persistence/Legacy/Filter/CriterionQueryBuilder/Location/BookmarkQueryBuilder.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace eZ\Publish\Core\Persistence\Legacy\Filter\CriterionQueryBuilder\Location; | ||
|
||
use Doctrine\DBAL\ParameterType; | ||
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Bookmark; | ||
use eZ\Publish\Core\Persistence\Legacy\Bookmark\Gateway\DoctrineDatabase; | ||
use eZ\Publish\SPI\Persistence\Filter\Doctrine\FilteringQueryBuilder; | ||
use eZ\Publish\SPI\Repository\Values\Filter\FilteringCriterion; | ||
|
||
/** | ||
* @internal for internal use by Repository Filtering | ||
*/ | ||
final class BookmarkQueryBuilder extends BaseLocationCriterionQueryBuilder | ||
{ | ||
public function accepts(FilteringCriterion $criterion): bool | ||
{ | ||
return $criterion instanceof Bookmark; | ||
} | ||
|
||
public function buildQueryConstraint( | ||
FilteringQueryBuilder $queryBuilder, | ||
FilteringCriterion $criterion | ||
): ?string { | ||
$queryBuilder | ||
->joinOnce( | ||
'location', | ||
DoctrineDatabase::TABLE_BOOKMARKS, | ||
'bookmark', | ||
'location.node_id = bookmark.node_id' | ||
); | ||
|
||
return $queryBuilder->expr()->eq( | ||
'bookmark.user_id', | ||
$queryBuilder->createNamedParameter( | ||
(int)$criterion->value[0], | ||
ParameterType::INTEGER | ||
) | ||
); | ||
} | ||
} |
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
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