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

BUG: NodeType $fullConfiguration is accessed when nodeType is not initialized. #4333

Closed
mhsdesign opened this issue Jun 13, 2023 · 3 comments

Comments

@mhsdesign
Copy link
Member

The NodeType (in 9.0) Has a TODO at the top

TODO: REFACTOR TO immutable readonly; and value objects

and that is pretty valid, as currently the nodeType is mutable and lazyloads its configuration.

This is problematic, in cases when we forget to call $this->initialize() before accessing $this->fullConfiguration.

I encountered this problem while testing, in my case getPropertyType didnt return the expected result.

public function getPropertyType($propertyName)
{
if (!isset($this->fullConfiguration['properties']) || !isset($this->fullConfiguration['properties'][$propertyName]) || !isset($this->fullConfiguration['properties'][$propertyName]['type'])) {
return 'string';
}
return $this->fullConfiguration['properties'][$propertyName]['type'];
}

doesnt initialize the nodetype ... but other methods trigger this sideeffect correctly like getProperties

public function getProperties()
{
$this->initialize();
return (isset($this->fullConfiguration['properties']) ? $this->fullConfiguration['properties'] : []);
}

A workaround is to call getFullConfiguration() before getPropertyType to initialize.

Other affected methods are fx. getTypeOfAutoCreatedChildNode

Affected Versions:

7.3 ... 9.0

mhsdesign added a commit to Flowpack/Flowpack.NodeTemplates that referenced this issue Jun 14, 2023
Sebobo added a commit to Flowpack/Flowpack.NodeTemplates that referenced this issue Jun 19, 2023
* BUGFIX: NodeType is not initialized in super rare edge cases

see neos/neos-development-collection#4333

* Update Classes/Domain/NodeCreation/PropertiesAndReferences.php

---------

Co-authored-by: Sebastian Helzle <sebastian@helzle.it>
@mhsdesign
Copy link
Member Author

And helllo there

// HACK the following line is required in order to fully initialize the node type

@bwaidelich
Copy link
Member

Great to finally have a bug report for this – we kept hacking around this issue, as you realized :)

IMO we should just add the initialize() call to all methods in the NodeType that require it.

For 9.0 I still hope that we can turn the NodeType into a less magic self-translating, lazy-loading beast with #4228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants