Skip to content
Snippets Groups Projects
Commit 4aea52e4 authored by Garvin Hicking's avatar Garvin Hicking
Browse files

[BUGFIX] Fix AbstractFormViewHelper type hint for identity map

With a larger refactoring of #96473 type hinting was introduced
for `AbstractFormViewHelper->renderHiddenIdentityField()`.

The phpdoc annotation previously hinted at the input being of
type 'object' (or null), and the type hint was thus set to
'object', too.

However, the argument restriction of a ViewHelper like
`FormViewHelper` defined an 'object' of type 'mixed',
and would thus allow arrays. Arrays do not need a
hidden identity field, so returning '' for that
would allow the ViewHelper to function properly.

With this patch, the type hint is changed to 'mixed'
now, so that previous ViewHelper usages with arrays
should be restored again and not lead to a type
exception.

Resolves: #105146
Resolves: #103162
Related: #96473
Releases: main, 12.4
Change-Id: I8a431e8909efb2e8d5ad041c69a0c75b7296c721
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/86367


Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: default avatarGarvin Hicking <gh@faktor-e.de>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarGarvin Hicking <gh@faktor-e.de>
Tested-by: default avatarcore-ci <typo3@b13.com>
parent ffba4680
Branches
No related merge requests found
......@@ -67,12 +67,12 @@ abstract class AbstractFormViewHelper extends AbstractTagBasedViewHelper
/**
* Renders a hidden form field containing the technical identity of the given object.
*
* @param object|null $object Object to create the identity field for
* @param mixed $object Object to create the identity field for. Non-objects are ignored.
* @param string|null $name Name
* @return string A hidden field containing the Identity (uid) of the given object
* @see \TYPO3\CMS\Extbase\Mvc\Controller\Argument::setValue()
*/
protected function renderHiddenIdentityField(?object $object, ?string $name): string
protected function renderHiddenIdentityField(mixed $object, ?string $name): string
{
if ($object instanceof LazyLoadingProxy) {
$object = $object->_loadRealInstance();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment