Skip to content

BUGFIX: Handle numeric node aggregate ids when building NodeAggregates#5727

Open
mhsdesign wants to merge 4 commits intoneos:9.0from
mhsdesign:bugfix/fully-numeric-node-aggregate-ids
Open

BUGFIX: Handle numeric node aggregate ids when building NodeAggregates#5727
mhsdesign wants to merge 4 commits intoneos:9.0from
mhsdesign:bugfix/fully-numeric-node-aggregate-ids

Conversation

@mhsdesign
Copy link
Member

Currently by not restricting numeric values like "132" in the NodeAggregateId validation we allow it. Yet the behaviour is utterly broken due to us being tricked by phps "feature" which converts numeric strings to integers when using it as array index. We often put node ids into a hashmap but get integers back and then fail recreating a node aggregate id and other funky cases. I hope i found all cases...

Type error: Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId::fromString(): Argument #1 ($value) must be of type string, int given, called in Packages/Neos/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php on line 290

A classic one thanks due to phps type casting for numeric array keys :)

$array['123'] will be stored as int 123 and not accessible via "123"

Additionally the SubtreeTags - pained by a similar bug - are now restricted to be never fully numeric. See discussion in Slack: https://neos-project.slack.com/archives/C04PYL8H3/p1767965980113829

Upgrade instructions

Review instructions

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

…ction

`fromArray` is not safe and throws when constructed with ["a", "123"]:
> Fatal error: Cannot use positional argument after named argument during unpacking

Because we pass the indexed array as spread to the constructor
Type error: Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId::fromString(): Argument neos#1 ($value) must be of type string, int given, called in Packages/Neos/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php on line 290

A classic one thanks due to phps type casting for numeric array keys :)

$array['123'] will be stored as int `123` and not accessible via `"123"`
…acter

The SubtreeTag value "456" does not adhere to the regular expression "/^[a-z_.-][a-z0-9_.-]{0,35}$/"

Otherwise fetching a node being tagged like this crashed in the NodeFactory in 323 because we
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant