Skip to content

Commit

Permalink
Merge pull request #4645 from neos/task/removeUnstructuredNodeType
Browse files Browse the repository at this point in the history
TASK: Remove legacy `unstructured` node type
  • Loading branch information
kitsunet authored Nov 2, 2023
2 parents 504e25e + 7af08e4 commit e51bc6d
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ public function run(): ProcessorResult
{
$numberOfErrors = 0;
foreach ($this->nodeDataRows as $nodeDataRow) {
if ($nodeDataRow['path'] === '/sites') {
// the sites node has no properties and is unstructured
continue;
}
$nodeTypeName = NodeTypeName::fromString($nodeDataRow['nodetype']);
try {
$nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName);
} catch (NodeTypeNotFoundException $exception) {
$numberOfErrors ++;
$this->dispatch(Severity::ERROR, '%s. Node: "%s"', $exception->getMessage(), $nodeDataRow['identifier']);
if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) {
$this->dispatch(Severity::ERROR, 'The node type "%s" is not available. Node: "%s"', $nodeTypeName->value, $nodeDataRow['identifier']);
continue;
}
// HACK the following line is required in order to fully initialize the node type
$nodeType->getFullConfiguration();
$nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName);
try {
$properties = json_decode($nodeDataRow['properties'], true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,24 @@ public function processNodeDataWithoutFallbackToEmptyDimension(NodeAggregateId $
$nodeName = end($pathParts);
assert($nodeName !== false);
$nodeTypeName = NodeTypeName::fromString($nodeDataRow['nodetype']);
$nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName);
$serializedPropertyValuesAndReferences = $this->extractPropertyValuesAndReferences($nodeDataRow, $nodeType);

$nodeType = $this->nodeTypeManager->hasNodeType($nodeTypeName) ? $this->nodeTypeManager->getNodeType($nodeTypeName) : null;

$isSiteNode = $nodeDataRow['parentpath'] === '/sites';
if ($isSiteNode && !$nodeType->isOfType(NodeTypeNameFactory::NAME_SITE)) {
if ($isSiteNode && !$nodeType?->isOfType(NodeTypeNameFactory::NAME_SITE)) {
throw new MigrationException(sprintf(
'The site node "%s" (type: "%s") must be of type "%s"', $nodeDataRow['identifier'], $nodeTypeName->value, NodeTypeNameFactory::NAME_SITE
), 1695801620);
}

if (!$nodeType) {
$this->dispatch(Severity::ERROR, 'The node type "%s" is not available. Node: "%s"', $nodeTypeName->value, $nodeDataRow['identifier']);
return;
}

$nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName);
$serializedPropertyValuesAndReferences = $this->extractPropertyValuesAndReferences($nodeDataRow, $nodeType);

if ($this->isAutoCreatedChildNode($parentNodeAggregate->nodeTypeName, $nodeName) && !$this->visitedNodes->containsNodeAggregate($nodeAggregateId)) {
// Create tethered node if the node was not found before.
// If the node was already visited, we want to create a node variant (and keep the tethering status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function iExpectTheFollowingEventsToBeExported(TableNode $table): void
*/
public function iExpectTheFollwingErrorsToBeLogged(TableNode $table): void
{
Assert::assertSame($this->loggedErrors, $table->getColumn(0), 'Expected logged errors do not match');
Assert::assertSame($table->getColumn(0), $this->loggedErrors, 'Expected logged errors do not match');
$this->loggedErrors = [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Feature: Export of used Assets, Image Variants and Persistent Resources
| language | en | en, de, ch | ch->de |
And using the following node types:
"""yaml
'unstructured': {}
'Neos.Neos:Site': {}
'Some.Package:Homepage':
superTypes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Feature: Simple migrations without content dimensions
Given using no content dimensions
And using the following node types:
"""yaml
'unstructured': {}
'Neos.Neos:Site': {}
'Some.Package:Homepage':
superTypes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Feature: Exceptional cases during migrations
Given using no content dimensions
And using the following node types:
"""yaml
'unstructured': {}
'Neos.Neos:Site': {}
'Some.Package:Homepage':
superTypes:
Expand Down Expand Up @@ -101,11 +100,11 @@ Feature: Exceptional cases during migrations
When I have the following node data rows:
| Identifier | Path | Properties | Node Type |
| sites | /sites | | |
| a | /sites/a | not json | Some.Package:SomeNodeType |
| a | /sites/a | not json | Some.Package:Homepage |
And I run the event migration
Then I expect a MigrationError with the message
"""
Failed to decode properties "not json" of node "a" (type: "Some.Package:SomeNodeType"): Could not convert database value "not json" to Doctrine Type flow_json_array
Failed to decode properties "not json" of node "a" (type: "Some.Package:Homepage"): Could not convert database value "not json" to Doctrine Type flow_json_array
"""

Scenario: Node variants with the same dimension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Feature: Migrations that contain nodes with "reference" or "references propertie
Given using no content dimensions
And using the following node types:
"""yaml
'unstructured': {}
'Neos.Neos:Site': {}
'Some.Package:Homepage':
superTypes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Feature: Migrating nodes with content dimensions
| language | en | en, de, ch | ch->de |
And using the following node types:
"""yaml
'unstructured': {}
'Neos.Neos:Site': {}
'Some.Package:Homepage':
superTypes:
'Neos.Neos:Site': true
'Some.Package:Thing': {}
"""
And using identifier "default", I define a content repository
And I am in content repository "default"
Expand Down Expand Up @@ -67,10 +67,10 @@ Feature: Migrating nodes with content dimensions
| Identifier | Path | Node Type | Dimension Values |
| sites | /sites | unstructured | |
| site | /sites/site | Some.Package:Homepage | {"language": ["de"]} |
| a | /sites/site/a | unstructured | {"language": ["de"]} |
| a1 | /sites/site/a/a1 | unstructured | {"language": ["de"]} |
| b | /sites/site/b | unstructured | {"language": ["de"]} |
| a1 | /sites/site/b/a1 | unstructured | {"language": ["ch"]} |
| a | /sites/site/a | Some.Package:Thing | {"language": ["de"]} |
| a1 | /sites/site/a/a1 | Some.Package:Thing | {"language": ["de"]} |
| b | /sites/site/b | Some.Package:Thing | {"language": ["de"]} |
| a1 | /sites/site/b/a1 | Some.Package:Thing | {"language": ["ch"]} |
And I run the event migration
Then I expect the following events to be exported
| Type | Payload |
Expand All @@ -88,11 +88,11 @@ Feature: Migrating nodes with content dimensions
| Identifier | Path | Node Type | Dimension Values |
| sites | /sites | unstructured | |
| site | /sites/site | Some.Package:Homepage | {"language": ["de"]} |
| a | /sites/site/a | unstructured | {"language": ["de"]} |
| a1 | /sites/site/a/a1 | unstructured | {"language": ["de"]} |
| b | /sites/site/b | unstructured | {"language": ["de"]} |
| a | /sites/site/b/a | unstructured | {"language": ["ch"]} |
| a1 | /sites/site/b/a/a1 | unstructured | {"language": ["ch"]} |
| a | /sites/site/a | Some.Package:Thing | {"language": ["de"]} |
| a1 | /sites/site/a/a1 | Some.Package:Thing | {"language": ["de"]} |
| b | /sites/site/b | Some.Package:Thing | {"language": ["de"]} |
| a | /sites/site/b/a | Some.Package:Thing | {"language": ["ch"]} |
| a1 | /sites/site/b/a/a1 | Some.Package:Thing | {"language": ["ch"]} |
And I run the event migration
Then I expect the following events to be exported
| Type | Payload |
Expand Down
5 changes: 0 additions & 5 deletions Neos.Neos/NodeTypes/Unstructured.yaml

This file was deleted.

0 comments on commit e51bc6d

Please sign in to comment.