2

I have an issue with different behaviour by replacing deprecated code. On my extension dedicated for Joomla! 3.10 i used this part of code :

$userid = $this->input->getInt('userid');
$this->user    = Factory::getUser($userid);

On the version of my extension dedicated for Joomla! 4.2.x i replaced by that :

$userid = $this->input->getInt('userid');
$this->user    = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userid);

On the case of $userid is null the call after to load the uersid doesn't work i get that :

Joomla\CMS\User\UserFactory::loadUserById(): Argument #1 ($id) must be of type int, null given, called in ...

1 Answer 1

2

Use integer 0 instead of null.

$userid = (int) $this->input->getInt('userid', 0);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.