Bug #98515
closed
Undefined array key with symfony expression results in log entries
Added by Ralph Brugger almost 2 years ago.
Updated over 1 year ago.
Description
Our typo3_error.log is full with PHP-Warnings like:
Exception: PHP Warning: Undefined array key "uid" in
typo3_src-11.5.16/vendor/symfony/expression-language/Node/GetAttrNode.php line 97,
{"expression":"page[\"uid\"] in [1209,1210,1208,5561,5005]",
"exception":"TYPO3\\CMS\\Core\\Error\\Exception: PHP Warning: Undefined array key \"uid\"
in typo3_src-11.5.16/vendor/symfony/expression-language/Node/GetAttrNode.php line 97
another example:
[(request.getQueryParams()['newsletter']) && (request.getQueryParams()['newsletter']) > 0]
Expression on not defined parameters should not result in an error log entry.
- Status changed from New to In Progress
- Assignee set to Frank Nägler
- Status changed from In Progress to Under Review
- Has duplicate Bug #95781: PHP Warning: Undefined array key "uid" in /app/vendor/symfony/expression-language/Node/GetAttrNode.php added
Stefan Bürk wrote in #note-6:
This is a known issue. You should take the effort to harden your TypoScript using the traverse() workaround to mitigate these errors.
This is an option, I agree. But it is also only a workaround. And blow up the conditions.
The example above is a simple example, but there are more complex conditions that blow up much more.
Userfriendly looks different to me ;)
Frank Nägler wrote in #note-7:
Stefan Bürk wrote in #note-6:
This is a known issue. You should take the effort to harden your TypoScript using the traverse() workaround to mitigate these errors.
This is an option, I agree. But it is also only a workaround. And blow up the conditions.
The example above is a simple example, but there are more complex conditions that blow up much more.
Userfriendly looks different to me ;)
I agree. We have many different conditions and it is a lot of work which are blowing up our log files.
Maybe we would rewrite them all, but it would be better - for newer user of TYPO3 - to get a them working without blowing up the logs.
Well, this is an issue of the underlying library and how it works in combination with PHP.
There were issues on symfony itself where they don't like to "fix" that as that's how it is supposed to work. That's why TYPO3 added the extra function.
I also thought it would be cool to "fix" that, but I changed my mind. It's the same as if you'd write the same in PHP. You also won't complain PHP to become more strict, but you'll fix the issue within your code and e.g. add `??` operator.
I understand that re writing a lot of conditions the same way is stupid. But rector can already do that. In fact it already migrates old condition syntax to new one. Should be possible to add the check and traverse re write to TYPO3 rector to do the job for everyone.
Same problem for me typo3 11.5.17 and php 8 and 8.1. strange thing is, if I put setup typoscript to database instead of file, there is no warning. activating same setup in file inklude I get php warning ...!?
- Related to Bug #94707: Undefined array key / Trying to access array offset on value of type null / PHP Version 8.0.8 added
- Related to Bug #100098: PHP Warning in Backend with php 8.2 added
Can we close this as duplicate of #95781.
(Most of the other related issues listed in #95781 are closed. I think it would be easier to handle in one issue)
- Status changed from Under Review to Rejected
rejected. see patch.
use traverse() or ?? operator to sanitize conditions.
Also available in: Atom
PDF