Bug #100338
closedTypeError due to missing type cast on pageUid in TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper
100%
Description
Hi,
we found an issue in class "TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper", method "renderStatic" on line number 77. The argument "pageUid" is used and causes an error in PHP 8.1 due to a missing type cast to integer.
As the UriBuilder requires the parameter for "setTargetPageUid()" to be an integer, the fix could be to add a type cast (int) like its done in any other ViewHelper class using a "pageUid".
The error can be reproduced by using an integer value from the settings array in fluid or by using a cObject type TEXT with a numeric value and pass it to the ViewHelper used in a plugin template (eg. EXT:felogin):
{f:uri.action(pageUid: '{f:cObject(typoscriptObjectPath: \'PAGEUID\')}', action: 'Action', controller: 'Controller', pluginName:'PluginName', extensionName: 'ExtensionName')}
OR
{f:uri.action(pageUid: '{settings.PAGEUID}', action: 'Action', controller: 'Controller', pluginName:'PluginName', extensionName: 'ExtensionName')}
Following solution could be applied:
Change
/** @var int $pageType */
$pageType = $arguments['pageType'] ?? 0;
to
/** @var int $pageType */
$pageType = (int)$arguments['pageType'] ?? 0;
Actual Result: We are getting a TypeError:
TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::setTargetPageUid(): Argument #1 ($targetPageUid) must be of type int, string given, called in /var/www/source-files/typo3_src-12.3.0/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ActionViewHelper.php on line 111
Expected Result: Getting an uri from from the viewhelper like "https://example.com/test?tx_extensionname_pluginname%5Baction%5D=Action&tx_extensionname_pluginname%5Bcontroller%5D=Controller&cHash=dbf5ada008ba1673f519e3248a13a434"
Additional notes:
We reproduced the error in TYPO3 11LTS running on PHP 8.1 aswell
Thank you!
Updated by Gerrit Code Review over 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78310
Updated by Gerrit Code Review over 1 year ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78310
Updated by Gerrit Code Review over 1 year ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78310
Updated by Gerrit Code Review over 1 year ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78310
Updated by Gerrit Code Review over 1 year ago
Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78310
Updated by Gerrit Code Review over 1 year ago
Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78310
Updated by Christian Kuhn over 1 year ago
- Related to Bug #96954: Deprecation notice when passing null format to DateViewHelper added
Updated by Christian Kuhn over 1 year ago
- Related to Bug #96953: Deprecation notice when passing null value to HtmlViewHelper added
Updated by Christian Kuhn over 1 year ago
i still thing these are bugs in fluid, see https://notes.typo3.org/X3W0AaGaSE2eB4xou7nIVg ... i think we should strive to fix it in fluid mid-term.
Updated by Gerrit Code Review over 1 year ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79214
Updated by Georg Ringer over 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset ecb8cac9aedbd7994ea7cfe7126abb172886ee26.
Updated by Gerrit Code Review over 1 year ago
- Status changed from Resolved to Under Review
Patch set 2 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79214
Updated by Gerrit Code Review over 1 year ago
Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79404
Updated by Georg Ringer over 1 year ago
- Status changed from Under Review to Resolved
Applied in changeset a25e48c87c8adf5b3d3acec33e0fca74ac1bf9af.
Updated by Mogens Fiebrandt over 1 year ago
This bug also occurs in the FormViewHelper:
https://github.com/TYPO3/typo3/blob/12.4/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php
The FormViewHelper doesn't extend the Link.ActionViewHelper or Uri.ActionViewHelper.
I reported a new Bug:
https://forge.typo3.org/issues/101486
Updated by Christian Kuhn over 1 year ago
- Related to Bug #101486: TypeError due to missing type cast on pageType in TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper added