Project

General

Profile

Actions

Bug #88848

closed

Cannot set null as targetPage in UriBuilder

Added by Robert Vock over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2019-07-26
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

#87629 hardened the UriBuilder of Extbase. Since then it is not possible to set null as targetPageUid, even though the comment for the property says null is allowed:
UriBuilder.php#L102


/**
 * @var int|null
 */
protected $targetPageUid;

UriBuilder.php#L426


public function setTargetPageUid(int $targetPageUid): UriBuilder
{
    $this->targetPageUid = $targetPageUid;
    return $this;
}

Other methods which do not allow null:
- setRequest
- setArgumentPrefix

The argument type hint should be adjusted and allow null: ?int, ?Request and ?string

Actions #1

Updated by Alexander Schnitzler over 5 years ago

Hi Robert,

what you describe is intended behaviour.
If you create a new instance of the UriBuilder, the default values for those properties with a null annotation are indeed null.
Therefore the type annotation says null|int etc.

When using the UriBuilder multiple times to generate different URL's, its reset method needs to be called which resets the internal state. But if you have a fresh instance, we don't want you to set the target page to null because you should only use the setter if you really need it to set meaningful values, not to reset the object state.

Does this answer you question?

Actions #2

Updated by Robert Vock over 5 years ago

Hi Alexander,

thanks for the quick reply and clearing that up. Yes, this answers my question and this issue can be closed.

I was using an extension which would always call the setTargetPageUid method without checking if the pageUid is null. That was the same way the f:uri.action ViewHelper worked before v10. But as I can see, that code got updated as well :)

Actions #3

Updated by Georg Ringer over 5 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF