Skip to content

Commit

Permalink
Remove the autoload_psr4 before running finalisation.php (#38525)
Browse files Browse the repository at this point in the history
Replaces gh-38491
  • Loading branch information
Nicholas K. Dionysopoulos committed Aug 18, 2022
1 parent 19f68b2 commit 30ab12a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
10 changes: 10 additions & 0 deletions administrator/components/com_joomlaupdate/extract.php
Expand Up @@ -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');
Expand Down
25 changes: 13 additions & 12 deletions administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
Expand Up @@ -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'))
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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' => '')
);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Expand Up @@ -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');
}

Expand Down

0 comments on commit 30ab12a

Please sign in to comment.