Skip to content

Commit

Permalink
TASK: Introduce NeosSubtreeTag::disabled
Browse files Browse the repository at this point in the history
And deprecate `SubtreeTag::disabled`

see discussion in neos#5463 (comment)

The only behavioural change is that with that the content repository does not know any subtree tag by default and thus the new default of the `StaticAuthProvider::getVisibilityConstraints` is to have nothing excluded!
  • Loading branch information
mhsdesign committed Mar 5, 2025
1 parent d716269 commit bd66e22
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\Feature\Security\Dto\Privilege;
use Neos\ContentRepository\Core\Feature\Security\Dto\UserId;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTags;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

Expand All @@ -31,7 +29,7 @@ public function getAuthenticatedUserId(): UserId

public function getVisibilityConstraints(WorkspaceName $workspaceName): VisibilityConstraints
{
return VisibilityConstraints::excludeSubtreeTags(SubtreeTags::create(SubtreeTag::disabled()));
return VisibilityConstraints::createEmpty();
}

public function canReadNodesFromWorkspace(WorkspaceName $workspaceName): Privilege
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public static function fromString(string $value): self
return self::instance($value);
}

/**
* Legacy, only for Neos.Neos context!, for standalone use please use {@see self::fromString()}
*
* Please use {@see \Neos\Neos\Domain\Service\NeosSubtreeTag::disabled()} instead.
*
* @deprecated with Neos 9 beta 19
*/
public static function disabled(): self
{
return self::instance('disabled');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use Neos\ContentRepository\Core\Feature\NodeVariation\Event\NodePeerVariantWasCreated;
use Neos\ContentRepository\Core\Feature\NodeVariation\Event\NodeSpecializationVariantWasCreated;
use Neos\ContentRepository\Core\Feature\RootNodeCreation\Event\RootNodeAggregateWithNodeWasCreated;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Event\SubtreeWasTagged;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Neos\ContentRepository\Core\NodeType\NodeType;
Expand All @@ -53,6 +52,7 @@
use Neos\ContentRepository\LegacyNodeMigration\RootNodeTypeMapping;
use Neos\Flow\Persistence\Doctrine\DataTypes\JsonArrayType;
use Neos\Flow\Property\PropertyMapper;
use Neos\Neos\Domain\Service\NeosSubtreeTag;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Webmozart\Assert\Assert;

Expand Down Expand Up @@ -274,7 +274,7 @@ public function processNodeDataWithoutFallbackToEmptyDimension(ProcessingContext
}
// nodes are hidden via SubtreeWasTagged event
if ($this->isNodeHidden($nodeDataRow)) {
$this->exportEvent(new SubtreeWasTagged($this->workspaceName, $this->contentStreamId, $nodeAggregateId, $this->interDimensionalVariationGraph->getSpecializationSet($originDimensionSpacePoint->toDimensionSpacePoint(), true, $this->visitedNodes->alreadyVisitedOriginDimensionSpacePoints($nodeAggregateId)->toDimensionSpacePointSet()), SubtreeTag::disabled()));
$this->exportEvent(new SubtreeWasTagged($this->workspaceName, $this->contentStreamId, $nodeAggregateId, $this->interDimensionalVariationGraph->getSpecializationSet($originDimensionSpacePoint->toDimensionSpacePoint(), true, $this->visitedNodes->alreadyVisitedOriginDimensionSpacePoints($nodeAggregateId)->toDimensionSpacePointSet()), NeosSubtreeTag::disabled()));
}

if (!$serializedPropertyValuesAndReferences->references->isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
Expand All @@ -24,6 +23,7 @@
use Neos\Eel\FlowQuery\FlowQueryException;
use Neos\Eel\FlowQuery\Operations\AbstractOperation;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Service\NeosSubtreeTag;

/**
* "context" operation working on ContentRepository nodes. Modifies the ContentRepository Context of each
Expand Down Expand Up @@ -116,8 +116,8 @@ public function evaluate(FlowQuery $flowQuery, array $arguments)
$newDimensions ?? $contextNode->dimensionSpacePoint,
VisibilityConstraints::excludeSubtreeTags(
match ($newInvisibleContentShown) {
true => $contextNode->visibilityConstraints->excludedSubtreeTags->without(SubtreeTag::disabled()),
false => $contextNode->visibilityConstraints->excludedSubtreeTags->with(SubtreeTag::disabled()),
true => $contextNode->visibilityConstraints->excludedSubtreeTags->without(NeosSubtreeTag::disabled()),
false => $contextNode->visibilityConstraints->excludedSubtreeTags->with(NeosSubtreeTag::disabled()),
null => $contextNode->visibilityConstraints->excludedSubtreeTags
}
)
Expand Down
28 changes: 26 additions & 2 deletions Neos.Neos/Classes/Domain/Service/NeosSubtreeTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Neos\Neos\Domain\Service;

use Neos\ContentRepository\Core\Feature\SubtreeTagging\Command\UntagSubtree;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;

/**
Expand All @@ -13,20 +14,43 @@
*
* By default, Neos provides two kinds of subtree tags:
*
* - `disabled` {@see SubtreeTag::disabled()} which is used when disabling a node
* - `disabled` {@see NeosSubtreeTag::disabled()} which is used when disabling a node
* - `removed` {@see NeosSubtreeTag::removed()} which is used when soft removing a node
*
* The visibility constraints {@see NeosVisibilityConstraints} define which tagged nodes are queried.
*
* @api
*/
final class NeosSubtreeTag
final readonly class NeosSubtreeTag
{
private function __construct()
{
// no instances
}

/**
* Content repository subtree tag which is used to denote that a node is disabled
*
* By default, disabled nodes never show up in the fronend rendering of a document.
*
* Disabling a node / its subtree is done via {@see TagSubtree}.
* In reverse enabling a node {@see UntagSubtree} is to be used.
*
* $contentRepository->handle(TagSubtree::create(
* $node->workspaceName,
* $node->aggregateId,
* $node->dimensionSpacePoint,
* NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS,
* NeosSubtreeTag::disabled()
* ));
*
* @api
*/
public static function disabled(): SubtreeTag
{
return SubtreeTag::fromString('disabled');
}

/**
* Content repository subtree tag which is used to denote that a node is soft removed
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Neos\Neos\Domain\Service;

use Neos\ContentRepository\Core\Feature\NodeDisabling\Command\DisableNodeAggregate;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTags;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
Expand All @@ -17,7 +15,7 @@
*
* By default, Neos provides two kinds of subtree tags:
*
* - `disabled` {@see SubtreeTag::disabled()} which is used when disabling a node via {@see DisableNodeAggregate}
* - `disabled` {@see NeosSubtreeTag::disabled()} which is used when disabling a node
* - `removed` {@see NeosSubtreeTag::removed()} which is used when soft removing a node
*
* To control which nodes will be queried via the {@see ContentSubgraphInterface}, the visibility constraints can be used.
Expand Down Expand Up @@ -50,7 +48,7 @@ private function __construct()
public static function excludeDisabled(): VisibilityConstraints
{
return VisibilityConstraints::excludeSubtreeTags(SubtreeTags::create(
SubtreeTag::disabled()
NeosSubtreeTag::disabled()
));
}

Expand Down
4 changes: 2 additions & 2 deletions Neos.Neos/Classes/Fusion/Helper/NodeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Neos\Neos\Fusion\Helper;

use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
Expand All @@ -28,6 +27,7 @@
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Exception;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;
use Neos\Neos\Domain\Service\NeosSubtreeTag;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Presentation\VisualNodePath;

Expand Down Expand Up @@ -103,7 +103,7 @@ public function isOfType(Node $node, string $nodeType): bool

public function isDisabled(Node $node): bool
{
return $node->tags->contain(SubtreeTag::disabled());
return $node->tags->contain(NeosSubtreeTag::disabled());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Neos.Neos/Classes/Service/LinkingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
namespace Neos\Neos\Service;

use GuzzleHttp\Psr7\Uri;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
Expand All @@ -28,6 +27,7 @@
use Neos\Media\Domain\Model\AssetInterface;
use Neos\Neos\Domain\Model\Site;
use Neos\Neos\Domain\Repository\SiteRepository;
use Neos\Neos\Domain\Service\NeosSubtreeTag;
use Neos\Neos\Exception as NeosException;
use Neos\Neos\FrontendRouting\NodeUriBuilder;
use Neos\Neos\Fusion\Helper\LinkHelper;
Expand Down Expand Up @@ -290,7 +290,7 @@ public function createNodeUri(
$mainRequest = $controllerContext->getRequest()->getMainRequest();
$uriBuilder = clone $controllerContext->getUriBuilder();
$uriBuilder->setRequest($mainRequest);
$createLiveUri = $workspace && $nodeAddress->workspaceName->isLive() && !$resolvedNode->tags->contain(SubtreeTag::disabled());
$createLiveUri = $workspace && $nodeAddress->workspaceName->isLive() && !$resolvedNode->tags->contain(NeosSubtreeTag::disabled());

if ($addQueryString === true) {
// legacy feature see https://github.com/neos/neos-development-collection/issues/5076
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Feature\NodeDisabling\Command\DisableNodeAggregate;
use Neos\ContentRepository\Core\Feature\NodeDisabling\Command\EnableNodeAggregate;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\NodeType\NodeTypeNames;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter;
Expand All @@ -21,6 +20,7 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Service\NeosSubtreeTag;
use Neos\Neos\Domain\Service\NeosVisibilityConstraints;
use Neos\TimeableNodeVisibility\Domain\ChangedVisibilities;
use Neos\TimeableNodeVisibility\Domain\ChangedVisibility;
Expand Down Expand Up @@ -48,7 +48,7 @@ public function handleExceededNodeDates(ContentRepositoryId $contentRepositoryId

/** @var Node $node */
foreach ($nodes as $node) {
$nodeIsDisabled = $node->tags->contain(SubtreeTag::disabled());
$nodeIsDisabled = $node->tags->contain(NeosSubtreeTag::disabled());
if ($this->needsEnabling($node, $now) && $nodeIsDisabled) {
$contentRepository->handle(
EnableNodeAggregate::create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface;
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteTrait;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Neos\Domain\Service\NeosSubtreeTag;
use Neos\TimeableNodeVisibility\Service\TimeableNodeVisibilityService;
use PHPUnit\Framework\Assert;

Expand Down Expand Up @@ -59,7 +59,7 @@ public function iExpectThisNodeToBeEnabled(): void
);
$currentNode = $subgraph->findNodeById($this->currentNode->aggregateId);
Assert::assertNotNull($currentNode, sprintf('Failed to find node with id "%s" in workspace %s and dimension %s', $this->currentNode->aggregateId->value, $subgraph->getWorkspaceName()->value, $subgraph->getDimensionSpacePoint()->toJson()));
Assert::assertFalse($currentNode->tags->contain(SubtreeTag::disabled()), sprintf('Node "%s" was expected to be enabled, but it is not', $this->currentNode->aggregateId->value));
Assert::assertFalse($currentNode->tags->contain(NeosSubtreeTag::disabled()), sprintf('Node "%s" was expected to be enabled, but it is not', $this->currentNode->aggregateId->value));
}

/**
Expand All @@ -74,7 +74,7 @@ public function iExpectThisNodeToBeDisabled(): void
);
$currentNode = $subgraph->findNodeById($this->currentNode->aggregateId);
Assert::assertNotNull($currentNode, sprintf('Failed to find node with id "%s" in workspace %s and dimension %s', $this->currentNode->aggregateId->value, $subgraph->getWorkspaceName()->value, $subgraph->getDimensionSpacePoint()->toJson()));
Assert::assertTrue($currentNode->tags->contain(SubtreeTag::disabled()), sprintf('Node "%s" was expected to be disabled, but it is not', $this->currentNode->aggregateId->value));
Assert::assertTrue($currentNode->tags->contain(NeosSubtreeTag::disabled()), sprintf('Node "%s" was expected to be disabled, but it is not', $this->currentNode->aggregateId->value));
}

protected function getContentRepositoryService(
Expand Down
8 changes: 4 additions & 4 deletions Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Dimension\ContentDimensionId;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Exception\WorkspaceAlreadyExists;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\ConflictingEvent;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Dto\RebaseErrorHandlingStrategy;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Exception\WorkspaceRebaseFailed;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter;
Expand Down Expand Up @@ -55,6 +55,7 @@
use Neos\Neos\Domain\Model\WorkspaceTitle;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;
use Neos\Neos\Domain\Repository\SiteRepository;
use Neos\Neos\Domain\Service\NeosSubtreeTag;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Domain\Service\UserService;
use Neos\Neos\Domain\Service\WorkspacePublishingService;
Expand All @@ -64,7 +65,6 @@
use Neos\Neos\PendingChangesProjection\ChangeFinder;
use Neos\Neos\PendingChangesProjection\Changes;
use Neos\Neos\Security\Authorization\ContentRepositoryAuthorizationService;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\ConflictingEvent;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;
use Neos\Workspace\Ui\ViewModel\ChangeItem;
use Neos\Workspace\Ui\ViewModel\ContentChangeItem;
Expand Down Expand Up @@ -915,7 +915,7 @@ protected function computeSiteChanges(Workspace $selectedWorkspace, ContentRepos
isRemoved: $change->deleted,
isNew: $change->created,
isMoved: $change->moved,
isHidden: $documentNode->tags->contain(SubtreeTag::disabled()),
isHidden: $documentNode->tags->contain(NeosSubtreeTag::disabled()),
);
}

Expand All @@ -939,7 +939,7 @@ protected function computeSiteChanges(Workspace $selectedWorkspace, ContentRepos
}
$siteChanges[$siteNodeName]['documents'][$documentPath]['changes'][$node->dimensionSpacePoint->hash][$relativePath] = new ChangeItem(
serializedNodeAddress: $nodeAddress->toJson(),
hidden: $node->tags->contain(SubtreeTag::disabled()),
hidden: $node->tags->contain(NeosSubtreeTag::disabled()),
isRemoved: $change->deleted,
isNew: $change->created,
isMoved: $change->moved,
Expand Down

0 comments on commit bd66e22

Please sign in to comment.