Toggles the enabled status of an update site. Update sites are disabled before getting the update information
from their URL and enabled afterwards. If the URL fetch fails with a PHP fatal error (e.g. timeout) the faulty
update site will remain disabled the next time we attempt to load the update information.
Parameters
- int $updateSiteId The numeric ID of the update site to enable/disable
- bool $enabled Enable the site when true, disable it when false
Returns
/**
* Toggles the enabled status of an update site. Update sites are disabled before getting the update information
* from their URL and enabled afterwards. If the URL fetch fails with a PHP fatal error (e.g. timeout) the faulty
* update site will remain disabled the next time we attempt to load the update information.
*
* @param int $updateSiteId The numeric ID of the update site to enable/disable
* @param bool $enabled Enable the site when true, disable it when false
*
* @return void
*/
protected function toggleUpdateSite($updateSiteId, $enabled = true)
{
$updateSiteId = (int) $updateSiteId;
$enabled = (bool) $enabled ? 1 : 0;
if (empty($updateSiteId)) {
return;
}
$db = $this->parent->getDbo();
$query = $db->getQuery(true)->update($db->quoteName('#__update_sites'))->set($db->quoteName('enabled') . ' = :enabled')->where($db->quoteName('update_site_id') . ' = :id')->bind(':enabled', $enabled, ParameterType::INTEGER)->bind(':id', $updateSiteId, ParameterType::INTEGER);
$db->setQuery($query);
try {
$db->execute();
} catch (\RuntimeException $e) {
// Do nothing
}
}