Project

General

Profile

Actions

Bug #100338

closed

TypeError due to missing type cast on pageUid in TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper

Added by Andreas Radermeker over 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2023-03-28
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.1
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

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!


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #96954: Deprecation notice when passing null format to DateViewHelperClosed2022-02-17

Actions
Related to TYPO3 Core - Bug #96953: Deprecation notice when passing null value to HtmlViewHelperClosed2022-02-17

Actions
Related to TYPO3 Core - Bug #101486: TypeError due to missing type cast on pageType in TYPO3\CMS\Fluid\ViewHelpers\FormViewHelperClosed2023-07-29

Actions
Actions

Also available in: Atom PDF