Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Add update channel reset to Joomla Update Component #43717

Open
wants to merge 9 commits into
base: 5.1-dev
Choose a base branch
from
Prev Previous commit
Next Next commit
Reset update channel from "Next" to "default"
Reset the core update channel from "Next" to "default" at the end of an update.
  • Loading branch information
richard67 committed Jun 22, 2024
commit 0b6167888b4d6e9ee711a51adaacb0a0bf76dc27
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,19 @@ public function finaliseUpgrade()
return false;
}

// Reset update source from "next" to "default"
try {
$this->resetUpdateSource();
} catch (\Throwable $e) {
$this->collectError('Reset update source to default', $e);
$msg .= Text::sprintf(
'COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_FAILED',
Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT'),
Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT')
)
. "\n";
}

if ($msg) {
$installer->set('extension_message', $msg);
}
Expand Down Expand Up @@ -2027,4 +2040,37 @@ private function checkManifestXML(string $manifest, $packageName)
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_DOWNGRADE', $packageName, $versionPackage, $currentVersion), 500);
}
}

/**
* Reset update source from "next" to "default"
*
* @return void
*
* @since __DEPLOY_VERSION__
* @throws \RuntimeException
*/
private function resetUpdateSource()
{
// Get current update source
$params = ComponentHelper::getParams('com_joomlaupdate');

// Do nothing if not "next"
if ($params->get('updatesource', 'default') !== 'next') {
return;
}

$params->set('updatesource', 'default');

$params = $params->toString();
$db = $this->getDatabase();
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('params') . ' = :params')
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
->where($db->quoteName('element') . ' = ' . $db->quote('com_joomlaupdate'))
->bind(':params', $params);

$db->setQuery($query);
$db->execute();
}
}