Skip to content

Commit ca2b306

Browse files
committed
fixup! IBX-10854: Not possible to hide content draft
1 parent 3891986 commit ca2b306

1 file changed

Lines changed: 22 additions & 21 deletions

File tree

src/lib/Repository/ContentService.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,17 +2528,17 @@ public function deleteTranslationFromDraft(APIVersionInfo $versionInfo, string $
25282528
*/
25292529
public function hideContent(ContentInfo $contentInfo): void
25302530
{
2531-
// If ContentInfo is in draft state, mainLocationId is yet not set
2532-
if (!$contentInfo->isDraft()) {
2533-
$locationTarget = (new DestinationLocationTarget($contentInfo->mainLocationId, $contentInfo));
2534-
if (!$this->permissionResolver->canUser(
2535-
'content',
2536-
'hide',
2537-
$contentInfo,
2538-
[$locationTarget]
2539-
)) {
2540-
throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]);
2541-
}
2531+
// If ContentInfo is in draft state, mainocationId is yet not set
2532+
$locationTarget = !$contentInfo->isDraft()
2533+
? [new DestinationLocationTarget($contentInfo->mainLocationId, $contentInfo)]
2534+
: [];
2535+
if (!$this->permissionResolver->canUser(
2536+
'content',
2537+
'hide',
2538+
$contentInfo,
2539+
$locationTarget
2540+
)) {
2541+
throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]);
25422542
}
25432543

25442544
$this->repository->beginTransaction();
@@ -2572,16 +2572,17 @@ public function hideContent(ContentInfo $contentInfo): void
25722572
public function revealContent(ContentInfo $contentInfo): void
25732573
{
25742574
// If ContentInfo is in draft state, mainLocationId is yet not set
2575-
if (!$contentInfo->isDraft()) {
2576-
$locationTarget = (new DestinationLocationTarget($contentInfo->mainLocationId, $contentInfo));
2577-
if (!$this->permissionResolver->canUser(
2578-
'content',
2579-
'hide',
2580-
$contentInfo,
2581-
[$locationTarget]
2582-
)) {
2583-
throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]);
2584-
}
2575+
$locationTarget = !$contentInfo->isDraft()
2576+
? [new DestinationLocationTarget($contentInfo->mainLocationId, $contentInfo)]
2577+
: [];
2578+
2579+
if (!$this->permissionResolver->canUser(
2580+
'content',
2581+
'hide',
2582+
$contentInfo,
2583+
[$locationTarget]
2584+
)) {
2585+
throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]);
25852586
}
25862587

25872588
$this->repository->beginTransaction();

0 commit comments

Comments
 (0)