public function cleanup() { // Anti-CSRF token check if ($this->csrfProtection) { $this->_csrfProtection(); } /** @var AkeebaModelUpdates $model */ $model = $this->getThisModel(); // Get information from the session $session = JFactory::getSession(); $updatePackagePath = $session->get('downloadedPackage', null, 'com_akeeba.update'); $installationDirectory = $session->get('installationDirectory', null, 'com_akeeba.update'); jimport('jooomla.filesystem.file'); jimport('jooomla.filesystem.folder'); jimport('joomla.installer.helper'); // Registers FTP credentials from the session $needsFTP = $model->needsFTPCredentials(); // First try using Joomla!'s cleanupInstall if (class_exists('JInstallerHelper') && method_exists('JInstallerHelper', 'cleanupInstall')) { JInstallerHelper::cleanupInstall($updatePackagePath, $installationDirectory); } // Make sure we have cleaned up the downloaded package if (is_file($updatePackagePath)) { if (!@unlink($updatePackagePath)) { JFile::delete($updatePackagePath); } } // Make sure we have cleaned up the extracted package's folder if (is_dir($installationDirectory)) { JFolder::delete($installationDirectory); } // Clear Joomla! caches if (class_exists('JCache') && method_exists('JCache', 'clean')) { F0FUtilsCacheCleaner::clearCacheGroups(array('mod_menu')); F0FUtilsCacheCleaner::clearPluginsCache(); F0FUtilsCacheCleaner::clearModulesCache(); } else { $cacheGroups = array('mod_menu', 'com_plugins', 'com_modules'); foreach ($cacheGroups as $group) { $cache = JFactory::getCache($group); $cache->clean(); } } // Force refresh the update information $model->getUpdates(true); // Reset Joomla!'s update cache as well $model->refreshUpdateSite(); }