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 11 months ago.

Status:
Resolved
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\FormViewHelperResolved2023-07-29

Actions
Actions #1

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

Actions #2

Updated by Gerrit Code Review about 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

Actions #3

Updated by Gerrit Code Review about 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

Actions #4

Updated by Gerrit Code Review about 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

Actions #5

Updated by Gerrit Code Review about 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

Actions #6

Updated by Gerrit Code Review about 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

Actions #7

Updated by Christian Kuhn about 1 year ago

  • Related to Bug #96954: Deprecation notice when passing null format to DateViewHelper added
Actions #8

Updated by Christian Kuhn about 1 year ago

  • Related to Bug #96953: Deprecation notice when passing null value to HtmlViewHelper added
Actions #9

Updated by Christian Kuhn about 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.

Actions #10

Updated by Gerrit Code Review about 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

Actions #11

Updated by Georg Ringer about 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #12

Updated by Gerrit Code Review about 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

Actions #13

Updated by Gerrit Code Review about 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

Actions #14

Updated by Georg Ringer about 1 year ago

  • Status changed from Under Review to Resolved
Actions #15

Updated by Mogens Fiebrandt 11 months 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

Actions #16

Updated by Christian Kuhn 11 months ago

  • Related to Bug #101486: TypeError due to missing type cast on pageType in TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper added
Actions

Also available in: Atom PDF