diff --git a/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php b/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php index 0e25ffd064470..79783cfdc631d 100644 --- a/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php +++ b/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php @@ -249,11 +249,17 @@ public function purge() // Purge updates /** @var \Joomla\Component\Joomlaupdate\Administrator\Model\UpdateModel $model */ - $model = $this->getModel('Update'); - $model->purge(); + $model = $this->getModel('Update'); + $result = $model->purge(); + + if ($result) { + $message = Text::_('COM_JOOMLAUPDATE_CHECKED_UPDATES'); + } else { + $message = Text::_('COM_JOOMLAUPDATE_FAILED_TO_CHECK_UPDATES'); + } $url = 'index.php?option=com_joomlaupdate'; - $this->setRedirect($url, $model->_message); + $this->setRedirect($url, $message); } /** diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index e9e3fbb82066a..5280ffb2ffa36 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -127,7 +127,7 @@ public function applyUpdateSite(?string $updateSource = null, ?string $updateURL $updateType = (pathinfo($updateURL, PATHINFO_EXTENSION) === 'xml') ? 'collection' : 'tuf'; $id = ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id; - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $db = $this->getDatabase(); $query = $db->createQuery() ->select($db->quoteName('us') . '.*') ->from($db->quoteName('#__update_sites_extensions', 'map')) @@ -200,7 +200,7 @@ public function refreshUpdates($force = false) */ public function getCheckForSelfUpdate() { - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $db = $this->getDatabase(); $query = $db->createQuery() ->select($db->quoteName('extension_id')) @@ -271,7 +271,7 @@ public function getUpdateInformation() // Fetch the update information from the database. $id = ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id; - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $db = $this->getDatabase(); $query = $db->createQuery() ->select('*') ->from($db->quoteName('#__updates')) @@ -343,7 +343,7 @@ public function getUpdateInformation() */ public function purge() { - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $db = $this->getDatabase(); // Modify the database record $update_site = new \stdClass(); @@ -357,15 +357,7 @@ public function purge() ->where($db->quoteName('update_site_id') . ' = 1'); $db->setQuery($query); - if ($db->execute()) { - $this->_message = Text::_('COM_JOOMLAUPDATE_CHECKED_UPDATES'); - - return true; - } - - $this->_message = Text::_('COM_JOOMLAUPDATE_FAILED_TO_CHECK_UPDATES'); - - return false; + return $db->execute(); } /** @@ -944,7 +936,7 @@ public function finaliseUpgrade() $installer->setUpgrade(true); $installer->setOverwrite(true); - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $db = $this->getDatabase(); $installer->extension = new \Joomla\CMS\Table\Extension($db); $installer->extension->load(ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id); @@ -983,9 +975,6 @@ public function finaliseUpgrade() return false; } - // Get a database connector object. - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); - /* * Check to see if a file extension by the same name is already installed. * If it is, then update the table because if the files aren't there @@ -1700,7 +1689,7 @@ private function getDatabaseSchemaCheck(): bool */ public function getNonCoreExtensions() { - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $db = $this->getDatabase(); $query = $db->createQuery(); $query->select( @@ -1748,7 +1737,7 @@ public function getNonCoreExtensions() */ public function getNonCorePlugins($folderFilter = ['system', 'user', 'authentication', 'actionlog', 'multifactorauth']) { - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $db = $this->getDatabase(); $query = $db->createQuery(); $query->select( @@ -1847,7 +1836,7 @@ public function fetchCompatibility($extensionID, $joomlaTargetVersion) private function getUpdateSitesInfo($extensionID) { $id = (int) $extensionID; - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $db = $this->getDatabase(); $query = $db->createQuery(); $query->select( @@ -2035,7 +2024,7 @@ protected function translateExtensionName(&$item) */ public function isTemplateActive($template) { - $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $db = $this->getDatabase(); $query = $db->createQuery(); $query->select( diff --git a/administrator/components/com_workflow/src/Controller/WorkflowController.php b/administrator/components/com_workflow/src/Controller/WorkflowController.php index af0c52bfdfb12..ed3ae3615b50d 100644 --- a/administrator/components/com_workflow/src/Controller/WorkflowController.php +++ b/administrator/components/com_workflow/src/Controller/WorkflowController.php @@ -11,6 +11,7 @@ namespace Joomla\Component\Workflow\Administrator\Controller; use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; @@ -183,7 +184,7 @@ public function postSaveHook(BaseDatabaseModel $model, $validData = []) $recordId = (int) $this->input->getInt($key); // @todo Moves queries out of the controller. - $db = $model->getDbo(); + $db = Factory::getDbo(); $query = $db->createQuery(); $query->select('*') diff --git a/libraries/src/MVC/Model/BaseDatabaseModel.php b/libraries/src/MVC/Model/BaseDatabaseModel.php index 4de18685ce29e..7d556563f7bea 100644 --- a/libraries/src/MVC/Model/BaseDatabaseModel.php +++ b/libraries/src/MVC/Model/BaseDatabaseModel.php @@ -107,9 +107,6 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null) if ($db) { @trigger_error('Database is not available in constructor in 6.0.', E_USER_DEPRECATED); $this->setDatabase($db); - - // Is needed, when models use the deprecated MVC DatabaseAwareTrait, as the trait is overriding the local functions - $this->setDbo($db); } // Set the default view search path @@ -394,7 +391,7 @@ protected function dispatchEvent(EventInterface $event) * @since 4.2.0 * @throws \UnexpectedValueException * - * @deprecated 4.3 will be removed in 7.0 + * @deprecated 4.3 will be removed in 8.0 * Use getDatabase() instead * Example: $model->getDatabase(); */ @@ -406,52 +403,4 @@ public function getDbo() throw new \UnexpectedValueException('Database driver not set in ' . __CLASS__); } } - - /** - * Set the database driver. - * - * @param ?DatabaseInterface $db The database driver. - * - * @return void - * - * @since 4.2.0 - * - * @deprecated 4.3 will be removed in 7.0 - * Use setDatabase() instead - * Example: $model->setDatabase($db); - */ - public function setDbo(?DatabaseInterface $db = null) - { - if ($db === null) { - return; - } - - $this->setDatabase($db); - } - - /** - * Proxy for _db variable. - * - * @param string $name The name of the element - * - * @return mixed The value of the element if set, null otherwise - * - * @since 4.2.0 - * - * @deprecated 4.3 will be removed in 7.0 - * Use getDatabase() instead of directly accessing _db - */ - public function __get($name) - { - if ($name === '_db') { - return $this->getDatabase(); - } - - // Default the variable - if (!isset($this->$name)) { - $this->$name = null; - } - - return $this->$name; - } }