/**
* Returns the IDs of the update sites with cached updates
*
* @param int $timestamp Optional. If set, only update sites checked before $timestamp will be taken into
* account.
*
* @return array The IDs of the update sites with cached updates
*
* @since 3.6.0
*/
private function getSitesWithUpdates($timestamp = 0)
{
$db = Factory::getDbo();
$timestamp = (int) $timestamp;
$query = $db->getQuery(true)->select('DISTINCT ' . $db->quoteName('update_site_id'))->from($db->quoteName('#__updates'));
if ($timestamp) {
$subQuery = $db->getQuery(true)->select($db->quoteName('update_site_id'))->from($db->quoteName('#__update_sites'))->where([$db->quoteName('last_check_timestamp') . ' IS NULL', $db->quoteName('last_check_timestamp') . ' <= :timestamp'], 'OR');
$query->where($db->quoteName('update_site_id') . ' IN (' . $subQuery . ')')->bind(':timestamp', $timestamp, ParameterType::INTEGER);
}
$retVal = $db->setQuery($query)->loadColumn(0);
if (empty($retVal)) {
return array();
}
return $retVal;
}