fix: replace all deprecated Factory::getDbo()/getApplication() with DI #165
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The codebase has 40+ calls to
Factory::getDbo()andFactory::getApplication()— deprecated in Joomla 5 and removed in Joomla 6. All models already use the correct$this->getDatabase()DI pattern; the standalone engine classes, plugins, CLI commands, and API controllers do not.Locations —
Factory::getDbo()Engine classes
BackupEngine.php—run()methodSteppedBackupEngine.php— lines 47, 264, 408, 451, 636, 700, 819SnapshotEngine.php— line 61SnapshotRestoreEngine.php— lines 65, 123, 419, 533PreflightCheck.php— line 42NotificationSender.php— line 265AkeebaImporter.php— line 47API controllers
api/src/Controller/SnapshotsController.php— lines 47, 209, 271api/src/Controller/BackupsController.php— line 41 (new BackupEngine()bypasses DI)Console commands (all 5)
ListCommand.php— line 41CleanupCommand.php— line 47ProfilesCommand.php— line 36RestoreCommand.php— line 45SnapshotCommand.php— lines 161, 214Plugins
plg_actionlog_mokosuitebackup— line 240plg_quickicon_mokosuitebackup— line 42plg_system_mokosuitebackup— lines 173, 245Install script
script.php— 10 occurrences (tolerable in install context but still deprecated)Locations —
Factory::getApplication()BackupEngine.php—dispatchAfterRun()line 809RestoreEngine.php— lines 155–157, 301SnapshotEngine.php— lines 177–178, 201–203, 343SnapshotRestoreEngine.php— lines 161–162, 533–534, 583NotificationSender.php— lines 65, 179, 385, 450What to do
DatabaseInterfacevia constructor injection in all Engine classesCMSApplicationInterfacevia constructor injection where needed$this->getDatabase()(available in Joomla 6 plugin base class)$this->getDatabase()from the base controllerWhy
Factory::getDbo()andFactory::getApplication()are deprecated in Joomla 5+ and planned for removal. Using DI enables proper testability and follows the pattern already established in all Model classes.BackupStatusHelperat line 31 already uses the correctFactory::getContainer()->get('DatabaseDriver')pattern — the engines should follow suit.Branch created:
feature/165-fix-replace-factory-getdbo-with-dependenfix: replace Factory::getDbo() with dependency-injected database in BackupEngineto refactor: replace all Factory::getDbo() calls with dependency-injected database across entire codebaserefactor: replace all Factory::getDbo() calls with dependency-injected database across entire codebaseto fix: replace all deprecated Factory::getDbo()/getApplication() with DI