Conversation
| // If content is in draft state, mainLocationId is yet not set | ||
| if ($contentInfo->mainLocationId !== null) { |
There was a problem hiding this comment.
If this is true, then a dedicated ContentInfo method should probably be introduced.
There was a problem hiding this comment.
@Steveb-p
Okay, so I first thought about adding function like this:
+ public function isInitialDraft(): bool
+ {
+ return $this->status === self::STATUS_DRAFT && $this->currentVersionNo === 1;
+ }
However, then I realized that this is not needed for ContentInfo as existing ContentInfo::isDraft() will do just fine. This method will only return true if Content in question has never been published. Once Content is published, ContentInfo::isDraft() will still return false when you create new drafts for that content.
Fixed in acbb2d8
alongosz
left a comment
There was a problem hiding this comment.
AFAIR this is by-design. There's no purpose to hiding content drafts because content drafts can be read by people with versionread policy, the same as hidden content can be accessed. Are you trying to fix some fatal error or enable hiding drafts? TL;DR;.
yes, it is. If you don't want content to be visible at time of publishing.
@alongosz edited.... |
|
There was a problem hiding this comment.
Doesn't this mean, with this change, that for drafts every user has ability to hide & reveal?
Because we won't be checking permission resolver for drafts.
|
@vidarl please make sure #667 (comment) is addressed, PR is rebased and the CI lits green. |
acbb2d8 to
ca2b306
Compare
…to hide content draft" This reverts commit 0de3f32.
|
@konradoboza |
| public function hideContent(ContentInfo $contentInfo): void | ||
| { | ||
| $locationTarget = (new DestinationLocationTarget($contentInfo->mainLocationId, $contentInfo)); | ||
| // If ContentInfo is in draft state, mainocationId is yet not set |
There was a problem hiding this comment.
| // If ContentInfo is in draft state, mainocationId is yet not set | |
| // If ContentInfo is in draft state, mainLocationId is yet not set |
| public function testHideContentDraft(): void | ||
| { | ||
| $publishedContent = $this->createContentForHideRevealDraftTests(false); | ||
| self::assertNotNull($publishedContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); |
There was a problem hiding this comment.
| self::assertNotNull($publishedContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); | |
| self::assertNotNull( | |
| $publishedContent->contentInfo->getMainLocationId(), | |
| 'Expected mainLocationId to be set for this test case.' | |
| ); |
| self::assertNotNull($publishedContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); | ||
| $location = $this->locationService->loadLocation($publishedContent->contentInfo->getMainLocationId()); | ||
|
|
||
| $content = $this->contentService->loadContent($publishedContent->contentInfo->id); |
There was a problem hiding this comment.
Is there ->getContentInfo()? If it is we should adjust usages.
| $content = $this->contentService->loadContent($publishedContent->contentInfo->id); | |
| $content = $this->contentService->loadContent($publishedContent->contentInfo->getId()); |
| $location = $this->locationService->loadLocation($publishedContent->contentInfo->getMainLocationId()); | ||
|
|
||
| $content = $this->contentService->loadContent($publishedContent->contentInfo->id); | ||
| self::assertTrue($content->contentInfo->isHidden, 'Content is not hidden'); |
There was a problem hiding this comment.
| self::assertTrue($content->contentInfo->isHidden, 'Content is not hidden'); | |
| self::assertTrue($content->contentInfo->isHidden(), 'Content is not hidden'); |
| public function testHideAndRevealContentDraft(): void | ||
| { | ||
| $publishedContent = $this->createContentForHideRevealDraftTests(true); | ||
| self::assertNotNull($publishedContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); |
There was a problem hiding this comment.
| self::assertNotNull($publishedContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); | |
| self::assertNotNull( | |
| $publishedContent->contentInfo->getMainLocationId(), | |
| 'Expected mainLocationId to be set for this test case.' | |
| ); |
| $parentContent = $this->contentService->loadContent($contents[0]->id); | ||
| $parentLocation = $this->locationService->loadLocation($parentContent->contentInfo->mainLocationId); | ||
|
|
||
| self::assertNotNull($parentContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); |
There was a problem hiding this comment.
| self::assertNotNull($parentContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); | |
| self::assertNotNull( | |
| $parentContent->contentInfo->getMainLocationId(), | |
| 'Expected mainLocationId to be set for this test case.' | |
| ); |
|
|
||
| $directChildContent = $this->contentService->loadContent($contents[1]->id); | ||
| $directChildLocation = $this->locationService->loadLocation($directChildContent->contentInfo->mainLocationId); | ||
| self::assertNotNull($directChildContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); |
There was a problem hiding this comment.
| self::assertNotNull($directChildContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); | |
| self::assertNotNull( | |
| $directChildContent->contentInfo->getMainLocationId(), | |
| 'Expected mainLocationId to be set for this test case.' | |
| ); |
| $directChildContent = $this->contentService->loadContent($contents[1]->id); | ||
| $directChildLocation = $this->locationService->loadLocation($directChildContent->contentInfo->mainLocationId); | ||
| self::assertNotNull($directChildContent->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); | ||
| $directChildLocation = $this->locationService->loadLocation($directChildContent->contentInfo->getMainLocationId()); |
There was a problem hiding this comment.
| $directChildLocation = $this->locationService->loadLocation($directChildContent->contentInfo->getMainLocationId()); | |
| $directChildLocation = $this->locationService->loadLocation( | |
| $directChildContent->contentInfo->getMainLocationId() | |
| ); |
| $directChildLocation = $this->locationService->loadLocation($directChildContent->contentInfo->getMainLocationId()); | ||
|
|
||
| $childContent = $this->contentService->loadContent($contents[2]->id); | ||
| self::assertNotNull($childContent->contentInfo->mainLocationId, 'Expected mainLocationId to be set for this test case.'); |
There was a problem hiding this comment.
| self::assertNotNull($childContent->contentInfo->mainLocationId, 'Expected mainLocationId to be set for this test case.'); | |
| self::assertNotNull( | |
| $childContent->contentInfo->getMainLocationId(), | |
| 'Expected mainLocationId to be set for this test case.' | |
| ); |
|
|
||
| $content = $this->createContentVersion2(); | ||
| $mainLocation = $this->locationService->loadLocation($content->contentInfo->mainLocationId); | ||
| self::assertNotNull($content->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); |
There was a problem hiding this comment.
| self::assertNotNull($content->contentInfo->getMainLocationId(), 'Expected mainLocationId to be set for this test case.'); | |
| self::assertNotNull( | |
| $content->contentInfo->getMainLocationId(), | |
| 'Expected mainLocationId to be set for this test case.' | |
| ); |





It is not possible to publish content in hidden state
For QA:
Documentation: