@@ -2531,14 +2531,17 @@ public function deleteTranslationFromDraft(APIVersionInfo $versionInfo, string $
25312531 */
25322532 public function hideContent (ContentInfo $ contentInfo ): void
25332533 {
2534- $ locationTarget = (new DestinationLocationTarget ($ contentInfo ->mainLocationId , $ contentInfo ));
2535- if (!$ this ->permissionResolver ->canUser (
2536- 'content ' ,
2537- 'hide ' ,
2538- $ contentInfo ,
2539- [$ locationTarget ]
2540- )) {
2541- throw new UnauthorizedException ('content ' , 'hide ' , ['contentId ' => $ contentInfo ->id ]);
2534+ // If content is in draft state, mainLocationId is yet not set
2535+ if ($ contentInfo ->mainLocationId !== null ) {
2536+ $ locationTarget = (new DestinationLocationTarget ($ contentInfo ->mainLocationId , $ contentInfo ));
2537+ if (!$ this ->permissionResolver ->canUser (
2538+ 'content ' ,
2539+ 'hide ' ,
2540+ $ contentInfo ,
2541+ [$ locationTarget ]
2542+ )) {
2543+ throw new UnauthorizedException ('content ' , 'hide ' , ['contentId ' => $ contentInfo ->id ]);
2544+ }
25422545 }
25432546
25442547 $ this ->repository ->beginTransaction ();
@@ -2571,14 +2574,17 @@ public function hideContent(ContentInfo $contentInfo): void
25712574 */
25722575 public function revealContent (ContentInfo $ contentInfo ): void
25732576 {
2574- $ locationTarget = (new DestinationLocationTarget ($ contentInfo ->mainLocationId , $ contentInfo ));
2575- if (!$ this ->permissionResolver ->canUser (
2576- 'content ' ,
2577- 'hide ' ,
2578- $ contentInfo ,
2579- [$ locationTarget ]
2580- )) {
2581- throw new UnauthorizedException ('content ' , 'hide ' , ['contentId ' => $ contentInfo ->id ]);
2577+ // If content is in draft state, mainLocationId is yet not set
2578+ if ($ contentInfo ->mainLocationId !== null ) {
2579+ $ locationTarget = (new DestinationLocationTarget ($ contentInfo ->mainLocationId , $ contentInfo ));
2580+ if (!$ this ->permissionResolver ->canUser (
2581+ 'content ' ,
2582+ 'hide ' ,
2583+ $ contentInfo ,
2584+ [$ locationTarget ]
2585+ )) {
2586+ throw new UnauthorizedException ('content ' , 'hide ' , ['contentId ' => $ contentInfo ->id ]);
2587+ }
25822588 }
25832589
25842590 $ this ->repository ->beginTransaction ();
0 commit comments