? Release Blocker ? Pending

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
23 Apr 2022

Pull Request for pr #37095.

Summary of Changes

The function in the deprecated Joomla\CMS\MVC\Model\DatabaseAwareTrait must have the same signature as the functions in the BaseDatabaseModel. Additionally it ensures, when a model is using that trait and extending the BaseDatabaseModel that the database is available as the functions in the trait are overloading the ones from the class. Actually this is not needed as the BaseDatabaseModel is using in 4.1 the MVC trait and in 4.2 the DB package trait.

Testing Instructions

Install the free version of akeeba backup and open the control panel of it in the back end.

Actual result BEFORE applying this Pull Request

It crashes with the following error:
Compile Error: Declaration of Joomla\CMS\MVC\Model\DatabaseAwareTrait::getDbo() must be compatible with Joomla\CMS\MVC\Model\BaseDatabaseModel::getDbo(): Joomla\Database\DatabaseInterface

Expected result AFTER applying this Pull Request

It works normally.

avatar laoneo laoneo - open - 23 Apr 2022
avatar laoneo laoneo - change - 23 Apr 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 23 Apr 2022
Category Libraries
avatar laoneo
laoneo - comment - 23 Apr 2022

@nikosdion any reason you explicitly load the MVC DatabaseAwareTrait in the control panel and update model?

avatar nikosdion
nikosdion - comment - 23 Apr 2022

@laoneo The use of the DatabaseAwareTrait in the ControlpanelModel is a leftover from an older version of the code. That model had started as extending from BaseModel and implementing the DatabaseAwareTrait. It was converted to extend from BaseDatabaseModel (even though it really doesn't quite fit into what BaseDatabaseModel is supposed to do) and I forgot to remove the usage of the trait.

The UpdatesModel does not use the trait, though, it simply extends from BaseDatabaseModel.

Perhaps you meant the UpgradeModel which extends from BaseModel and uses DatabaseAwareTrait? This model is loaded from the installation script in the postflight event. At this point I may not be able to pass an MVCFactoryInterface (if it's a clean installation, not an update) but I definitely need access to Joomla's database. I could either pepper my model with Factory::getContainer()->get('DatabaseDriver') or use the DatabaseAwareTrait and set the DB object once. I chose the latter because it reduces the number of places I will have to change something when inevitably a future version of Joomla changes the way we access the DB driver object. Sure, it took 15 years to go from JFactory::getDbo() to Factory::getContainer()->get('DatabaseDriver') but here I am, having had to do that change in hundreds of places across dozens of extensions ? Then again, the UpgradeModel doesn't match your PR so I am not sure you really meant that model.

avatar laoneo
laoneo - comment - 23 Apr 2022

Thanks for the explanation.

avatar laoneo laoneo - change - 25 Apr 2022
Labels Added: Release Blocker ?
avatar joomla-cms-bot joomla-cms-bot - change - 25 Apr 2022
Category Libraries Libraries Unit Tests
avatar laoneo laoneo - change - 25 Apr 2022
Labels Added: ?
18e2f1d 25 Apr 2022 avatar laoneo cs
avatar roland-d roland-d - change - 25 Apr 2022
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-04-25 21:22:55
Closed_By roland-d
avatar roland-d roland-d - close - 25 Apr 2022
avatar roland-d roland-d - merge - 25 Apr 2022
avatar roland-d
roland-d - comment - 25 Apr 2022

Thanks guys.

Add a Comment

Login with GitHub to post a comment