User tests: Successful: Unsuccessful:
Pull Request to fix on PHP 8.0 an issue with "Notice: Only variable references should be returned by reference in /srv/www/joomla/joomla-cms/libraries/src/MVC/Model/BaseDatabaseModel.php on line 418"
Environment:
In a fresh installed Joomla 4 with the sample data for testing, under "Menus" open a menu item like "All Modules".
Or directly go to: administrator/index.php?option=com_menus&view=items&menutype=all-modules
(most of the other menu items have this issue)
and see the notice appear
Notice: Only variable references should be returned by reference in /srv/www/joomla/joomla-cms/libraries/src/MVC/Model/BaseDatabaseModel.php on line 418
Notice: Only variable references should be returned by reference in /srv/www/joomla/joomla-cms/libraries/src/MVC/Model/BaseDatabaseModel.php on line 418
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Thanks, I was already afraid that removing the ampersand before the function name would be too easy and probably not be the definitive solution :-)
I have tested this item
Tested successfully in Joomla 4.2.0-alpha3-dev of 27 April in Wampserver 3.2.8 using PHP 8.0.15.
I have tested this item
Thanks, I was already afraid that removing the ampersand before the function name would be too easy and probably not be the definitive solution :-)
I guess removing the ampersand is fine, but we need to adapt the unit test
Can you replace the unit test function with this more real world scenario:
public function testNotDeclaredVariable()
{
$model = new class(['dbo' => $this->createStub(DatabaseInterface::class)], $this->createStub(MVCFactoryInterface::class)) extends BaseDatabaseModel
{
public function cache($key, $value)
{
if (!isset($this->test[$key]))
{
$this->test[$key] = $value;
}
return $this->test[$key];
}
};
$this->assertEquals('test', $model->cache(1, 'test'));
}
Labels |
Added:
?
?
|
Category | Libraries | ⇒ | Libraries Unit Tests |
Labels |
Added:
?
Removed: ? |
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-04-29 12:23:34 |
Closed_By | ⇒ | laoneo |
Thanks!
Thanks. I guess this needs a bit more rethinking, because of undeclared variable references.