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

[BUGFIX] Throw array conversion exception in AbstractNode->castToString() #827

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

sbuerk
Copy link
Contributor

@sbuerk sbuerk commented Oct 31, 2023

AbstractNode->castToString() already checked for objects which could not
converted to a string representation due to missing __toString() method.
It's possible that the value could be an array, which per nature is not
really convertable to a string anyway. Older php versions simply converted
it to an Array string along with a notices, which has been raised to a
warning in newer PHP versions.

There is no way to properly convert an array, therefore the PHP warning
should always lead to an parser exception like for object not convertable.

This change now checks explicitly for an array and throws a corresponding
TYPO3Fluid\Fluid\Core\Parser\Exception with a meaningfull message.

Test is extended to cover this case.

Resolves: #826

…ing()`

`AbstractNode->castToString()` already checked for objects which could not
converted to a string representation due to missing `__toString()` method.
It's possible that the value could be an array, which per nature is not
really convertable to a string anyway. Older php versions simply converted
it to an `Array` string along with a notices, which has been raised to a
warning in newer PHP versions.

There is no way to properly convert an array, therefore the PHP warning
should always lead to an parser exception like for object not convertable.

This change now checks explicitly for an array and throws a corresponding
`TYPO3Fluid\Fluid\Core\Parser\Exception` with a meaningfull message.

Test is extended to cover this case.

Resolves: #826
@s2b
Copy link
Contributor

s2b commented Nov 20, 2023

I agree that a proper exception should be thrown for this. However, this might break existing templates where PHP warnings are suppressed. Not sure if this is a problem?

@s2b s2b merged commit 379041b into main Nov 21, 2023
4 checks passed
@s2b s2b deleted the stefan-2 branch November 21, 2023 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Array to string conversion warning in AbstractNode
2 participants