Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!! TASK: Remove Node::nodeType #5021

Merged
merged 4 commits into from
Jul 3, 2024

Conversation

mhsdesign
Copy link
Member

@mhsdesign mhsdesign commented Apr 30, 2024

Requires #5020 in the long term

With #4466 the fallback NodeType handling was removed from the core NodeType manager and extracted to Neos. See the trait NodeTypeWithFallbackProvider.
That required to make the nodeType field nullable on the NodeType.

This pr takes it a bit further by fully removing the attached NodeType schema from the Node.
The Node attached NodeType was declared as deprecated with Neos9-Beta10.

Resolves: #5019

Upgrade instructions

In Fusion accessing the NodeType via ${node.nodeType} wont work longer but one can leverage the helper ${Neos.Node.getNodeType(node)} to access the NodeType.

To get the NodeType for a Node in PHP, one can either use the Node::nodeTypeName and ask the Neos\ContentRepository\Core\NodeType\NodeTypeManager::getNodeType:

+ $nodeTypeManager->getNodeType($node->nodeTypeName);
- $node->nodeType;

For just accessing the string of the NodeType name you can consult the Node directly:

- $node->getNodeType()->getName();
+ $node->nodeTypeName->value;

Also note that getNodeType was made nullable by removing the default fallback. change
To restore this behaviour you can use the Neos\Neos\Utility\NodeTypeWithFallbackProvider trait which will return a NodeType instance for any Node considering the Fallback (the Neos.Neos:FallbackNode) in case the requested NodeType was removed. Please note that this behaviour is discouraged in favour of using nullable NodeTypes:

+ #[Flow\Inject]
+ protected ContentRepositoryRegistry $contentRepositoryRegistry;
+
+ use NodeTypeWithFallbackProvider;
+
+ $this->getNodeType($node);
- $node->nodeType;

Review instructions

Followup node.nodeType viewhelper for fluid (see also #5023)
Rector migrations will be provided as part of neos/rector#57

Checklist

  • Code follows the PSR-2 coding style
  • Tests have been created, run and adjusted as needed
  • The PR is created against the lowest maintained branch
  • Reviewer - PR Title is brief but complete and starts with FEATURE|TASK|BUGFIX
  • Reviewer - The first section explains the change briefly for change-logs
  • Reviewer - Breaking Changes are marked with !!! and have upgrade-instructions

@github-actions github-actions bot added the 9.0 label Apr 30, 2024
Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks for taking care!

But since this is a breaking change that will affect most installations, we should make sure that we have

  • A proper description with explanations on how to migrate code
  • Rector migration for Fusion code
  • Rector migration for PHP code

And IMO we should have those in place before we merge this one – at least the first one :)

The `NodeTypeManager` must be asked instead.
For Neos' fallback logic the `NodeTypeWithFallbackProvider` can be used.
Copy link
Member

@kitsunet kitsunet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, all according to plan!

@pKallert
Copy link
Contributor

pKallert commented Jul 2, 2024

The nodetype is also still used in https://github.com/neos/neos-development-collection/blob/9.0/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php#L93.
I am not sure if this is relevant here, since the tests seem to run through? Could at least be worth looking at :)

@mhsdesign
Copy link
Member Author

Thanks for your throughout review @pKallert the NodeHelperTest must be rewritten to behat at some point see comment:

Skipped. Either migrate to behat or find a better way to mock node read models. See #4317

@mhsdesign mhsdesign requested a review from pKallert July 2, 2024 14:55
Copy link
Contributor

@pKallert pKallert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@mhsdesign mhsdesign merged commit 2348270 into neos:9.0 Jul 3, 2024
9 checks passed
@mhsdesign mhsdesign deleted the task/5019-remove-nodetype-from-node branch July 3, 2024 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decouple Node read-model from NodeType (remove Node::nodeType field)
4 participants