diff --git a/administrator/components/com_joomlaupdate/extract.php b/administrator/components/com_joomlaupdate/extract.php index 2ca3730f8e19b..737e15a3bf4e4 100644 --- a/administrator/components/com_joomlaupdate/extract.php +++ b/administrator/components/com_joomlaupdate/extract.php @@ -1930,6 +1930,16 @@ function setHugeMemoryLimit() case 'finalizeUpdate': $root = $configuration['setup.destdir'] ?? ''; + // Remove the administrator/cache/autoload_psr4.php file + $filename = $root . (empty($root) ? '' : '/') . 'administrator/cache/autoload_psr4.php'; + + if (file_exists($filename)) { + clearFileInOPCache($filename); + clearstatcache(true, $filename); + + @unlink($filename); + } + // Remove update.php clearFileInOPCache($basePath . 'update.php'); @unlink($basePath . 'update.php'); diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index 84045ba3c8600..d9ccacdf56e7c 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -95,7 +95,7 @@ public function applyUpdateSite() } $id = ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id; - $db = $this->getDatabase(); + $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); $query = $db->getQuery(true) ->select($db->quoteName('us') . '.*') ->from($db->quoteName('#__update_sites_extensions', 'map')) @@ -173,7 +173,7 @@ public function refreshUpdates($force = false) */ public function getCheckForSelfUpdate() { - $db = $this->getDatabase(); + $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); $query = $db->getQuery(true) ->select($db->quoteName('extension_id')) @@ -244,7 +244,7 @@ public function getUpdateInformation() // Fetch the update information from the database. $id = ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id; - $db = $this->getDatabase(); + $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); $query = $db->getQuery(true) ->select('*') ->from($db->quoteName('#__updates')) @@ -300,7 +300,7 @@ public function getUpdateInformation() */ public function purge() { - $db = $this->getDatabase(); + $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); // Modify the database record $update_site = new \stdClass(); @@ -632,7 +632,8 @@ public function finaliseUpgrade() $installer->setUpgrade(true); $installer->setOverwrite(true); - $installer->extension = new \Joomla\CMS\Table\Extension($this->getDatabase()); + $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); + $installer->extension = new \Joomla\CMS\Table\Extension($db); $installer->extension->load(ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id); $installer->setAdapter($installer->extension->type); @@ -667,7 +668,7 @@ public function finaliseUpgrade() ob_end_clean(); // Get a database connector object. - $db = $this->getDatabase(); + $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. @@ -694,7 +695,7 @@ public function finaliseUpgrade() } $id = $db->loadResult(); - $row = new \Joomla\CMS\Table\Extension($this->getDatabase()); + $row = new \Joomla\CMS\Table\Extension($db); if ($id) { // Load the entry and update the manifest_cache. @@ -779,7 +780,7 @@ public function finaliseUpgrade() ob_end_clean(); // Clobber any possible pending updates. - $update = new \Joomla\CMS\Table\Update($this->getDatabase()); + $update = new \Joomla\CMS\Table\Update($db); $uid = $update->find( array('element' => 'joomla', 'type' => 'file', 'client_id' => '0', 'folder' => '') ); @@ -1325,7 +1326,7 @@ private function getDatabaseSchemaCheck(): bool */ public function getNonCoreExtensions() { - $db = $this->getDatabase(); + $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); $query = $db->getQuery(true); $query->select( @@ -1375,7 +1376,7 @@ public function getNonCoreExtensions() */ public function getNonCorePlugins($folderFilter = ['system','user','authentication','actionlog','multifactorauth']) { - $db = $this->getDatabase(); + $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); $query = $db->getQuery(true); $query->select( @@ -1476,7 +1477,7 @@ public function fetchCompatibility($extensionID, $joomlaTargetVersion) private function getUpdateSitesInfo($extensionID) { $id = (int) $extensionID; - $db = $this->getDatabase(); + $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); $query = $db->getQuery(true); $query->select( @@ -1659,7 +1660,7 @@ protected function translateExtensionName(&$item) */ public function isTemplateActive($template) { - $db = $this->getDatabase(); + $db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase(); $query = $db->getQuery(true); $query->select( diff --git a/administrator/components/com_joomlaupdate/src/View/Joomlaupdate/HtmlView.php b/administrator/components/com_joomlaupdate/src/View/Joomlaupdate/HtmlView.php index 9e8e35c226c31..b9c19ba76ab5d 100644 --- a/administrator/components/com_joomlaupdate/src/View/Joomlaupdate/HtmlView.php +++ b/administrator/components/com_joomlaupdate/src/View/Joomlaupdate/HtmlView.php @@ -275,7 +275,11 @@ protected function addToolbar() } // Add toolbar buttons. - if ($this->getCurrentUser()->authorise('core.admin')) { + $currentUser = version_compare(JVERSION, '4.2.0', 'ge') + ? $this->getCurrentUser() + : Factory::getApplication()->getIdentity(); + + if ($currentUser->authorise('core.admin')) { ToolbarHelper::preferences('com_joomlaupdate'); }