Skip to content

Commit fa2865d

Browse files
committed
TASK: Catch error because of legacy internal property names
1 parent 4fa4f45 commit fa2865d

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

Classes/Domain/NodeCreation/PropertiesAndReferences.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ public static function createFromArrayAndTypeDeclarations(array $propertiesAndRe
5353
public function requireValidProperties(NodeType $nodeType, CaughtExceptions $caughtExceptions): array
5454
{
5555
$validProperties = [];
56-
$defaultValues = $nodeType->getDefaultValuesForProperties();
5756
foreach ($this->properties as $propertyName => $propertyValue) {
58-
$this->assertValidPropertyName($propertyName);
5957
try {
58+
$this->assertValidPropertyName($propertyName);
6059
if (!isset($nodeType->getProperties()[$propertyName])) {
6160
throw new PropertyIgnoredException(
6261
sprintf(
@@ -109,20 +108,20 @@ public function requireValidReferences(NodeType $nodeType, Context $subgraph, Ca
109108

110109
/**
111110
* In the old CR, it was common practice to set internal or meta properties via this syntax: `_hidden` but we don't allow this anymore.
112-
* @throws \InvalidArgumentException
111+
* @throws PropertyIgnoredException
113112
*/
114113
private function assertValidPropertyName($propertyName): void
115114
{
116115
$legacyInternalProperties = ['_accessRoles', '_contentObject', '_hidden', '_hiddenAfterDateTime', '_hiddenBeforeDateTime', '_hiddenInIndex',
117116
'_index', '_name', '_nodeType', '_removed', '_workspace'];
118117
if (!is_string($propertyName) || $propertyName === '') {
119-
throw new \InvalidArgumentException(sprintf('Property name must be a non empty string. Got "%s".', $propertyName));
118+
throw new PropertyIgnoredException(sprintf('Because property name must be a non empty string. Got "%s".', $propertyName), 1686149518395);
120119
}
121120
if ($propertyName[0] === '_') {
122121
$lowerPropertyName = strtolower($propertyName);
123122
foreach ($legacyInternalProperties as $legacyInternalProperty) {
124123
if ($lowerPropertyName === strtolower($legacyInternalProperty)) {
125-
throw new \InvalidArgumentException(sprintf('Internal legacy property "%s" not implement.', $propertyName));
124+
throw new PropertyIgnoredException(sprintf('Because internal legacy property "%s" not implement.', $propertyName), 1686149513158);
126125
}
127126
}
128127
}

Configuration/Testing/NodeTypes.Malformed.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
template:
3434
properties:
3535
foo: "${cannotCallThis()}"
36+
# legacy properties fail
37+
_hidden: true
38+
_hiddenAfterDateTime: 123
3639
boolValue: 123
3740
stringValue: false
3841
reference: "non-existing-node-id"

Tests/Functional/Fixtures/WithEvaluationExceptions.messages.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
"message": "Configuration \"null\" in \"childNodes.withItemsAbortBecauseNotIterable.withItems\" | RuntimeException(Type NULL is not iterable., 1685802354186)",
4444
"severity": "ERROR"
4545
},
46+
{
47+
"message": "Property \"_hidden\" in NodeType \"Flowpack.NodeTemplates:Content.WithEvaluationExceptions\" | PropertyIgnoredException(Because internal legacy property \"_hidden\" not implement., 1686149513158)",
48+
"severity": "ERROR"
49+
},
50+
{
51+
"message": "Property \"_hiddenAfterDateTime\" in NodeType \"Flowpack.NodeTemplates:Content.WithEvaluationExceptions\" | PropertyIgnoredException(Because internal legacy property \"_hiddenAfterDateTime\" not implement., 1686149513158)",
52+
"severity": "ERROR"
53+
},
4654
{
4755
"message": "Property \"boolValue\" in NodeType \"Flowpack.NodeTemplates:Content.WithEvaluationExceptions\" | PropertyIgnoredException(Because value `123` is not assignable to property type \"boolean\"., 1685958105644)",
4856
"severity": "ERROR"

Tests/Functional/Fixtures/WithEvaluationExceptions.template.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"properties": {
3+
"_hidden": true,
4+
"_hiddenAfterDateTime": 123,
35
"boolValue": 123,
46
"stringValue": false,
57
"reference": "non-existing-node-id",

0 commit comments

Comments
 (0)