Bug #88848
closedCannot set null as targetPage in UriBuilder
0%
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;
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
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?
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 :)