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 Make NodeType::getPropertyType throw #4480

Merged
merged 3 commits into from
Nov 2, 2023

Conversation

mhsdesign
Copy link
Member

@mhsdesign mhsdesign commented Sep 4, 2023

Previously - in Neos 8.x - NodeType::getPropertyType would fallback to "string" if no property is declared. This behaviour is hard to work with and an exception will be thrown instead.

NodeType schema has no property "undeclared-property" configured for the NodeType "Vendor:NodeType". Cannot read its type.

resolves #4477

Upgrade instructions

To migrate your code its recommended to check if a NodeType actually has the property before accessing its type as this could result in an exception.

- $type = $nodeType->getPropertyType('foo');
+ $type = $nodeType->hasProperty('foo') ? $nodeType->getPropertyType('foo') : 'string';

Optionally you could also use the newly introduced NodeType::hasProperty to clean up some a previous workaround to check if a node has a property:

- $exists = isset($nodeType->getProperties()['foo']);
+ $exists = $nodeType->hasProperty('foo');

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

@github-actions github-actions bot added the 9.0 label Sep 4, 2023
@mhsdesign mhsdesign force-pushed the task/4477-NodeType-getPropertyType-nullable branch from 68fe590 to ac88f59 Compare September 18, 2023 18:41
NodeType schema has no property "undefined" configured. Cannot read its type.
@mhsdesign mhsdesign changed the title !!! TASK Make NodeType::getPropertyType nullable !!! TASK Make NodeType::getPropertyType throw Oct 20, 2023
@ahaeslich ahaeslich merged commit 3c97184 into 9.0 Nov 2, 2023
5 checks passed
@ahaeslich ahaeslich deleted the task/4477-NodeType-getPropertyType-nullable branch November 2, 2023 09:53
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.

!!! 9.0 Make NodeType::getPropertyType throw instead of returning "string"
5 participants