FluidTYPO3 / vhs

TYPO3 extension VHS: Fluid ViewHelpers
https://fluidtypo3.org
Other
190 stars 229 forks source link

BUG: problem with php-warning in AbstractContentViewHelper in version 6.1.3 #1900

Closed Padina14 closed 4 months ago

Padina14 commented 4 months ago

I have checked that the bug exists in the dev-development branch yes

I have checked that there are no already open issues or recently closed issues about this bug yes

Describe the bug I got a exception about an php warning related to the index of an array. I use PHP 8.2 , Typo3 11.5.34.

To Reproduce I neede to install the attached patch to prevent this bug.
vhs_AbstractContentViewHelper.patch

Padina14 commented 4 months ago

Saver should be the following patch. vhs_AbstractContentViewHelper.patch

NamelessCoder commented 4 months ago

This problem does not exist in dev-development and version 7.0+, see https://github.com/FluidTYPO3/vhs/blob/development/Classes/ViewHelpers/Content/AbstractContentViewHelper.php#L236. No further releases will be made in the 6.x branches so I suggest you upgrade VHS to the latest major version 7.0+ (which is compatible with your PHP and TYPO3 versions).

Padina14 commented 4 months ago

The PHP-code in that place of the patch will cause an error. I added a screenshot from a sandbox for causing the same warning, which caused the exception in my case.

PHP has changed its behavior in the newer versions. The error would caused in version 7.0 in the same way; or can you guarantee, that the value $GLOBALS['TSFE']->recordRegister[$parent] is defined everytime?

Bildschirmfoto 2024-02-20 um 14 22 29

NamelessCoder commented 4 months ago

Look at the link I posted. There's an added isset() check (which does not throw the warning if the index doesn't exist) and if the variable doesn't exist, we initialize it with a value of 1. If it does exist, we increment it same as before. So yes, the variable is guaranteed to be defined.

The variable is then decremented later without a corresponding isset() check because at that point, the variable is guaranteed to exist.

Padina14 commented 4 months ago

Sorry. My Mistake. I havn't read your comment deeply and the code of the develop deeply enough. I am really sorry.

NamelessCoder commented 4 months ago

All good @Padina14 :)