2c2 < index 23199a8..c3be627 100644 --- > index 23199a8..d70c781 100644 32c32 < @@ -66,16 +68,29 @@ function hosting_lets_encrypt_queue($count) { --- > @@ -66,20 +68,29 @@ function hosting_lets_encrypt_queue($count) { 40c40,59 < + $where_extra = ''; --- > - if ($result = db_query('SELECT s.nid ' > - . 'FROM {hosting_site} s, {hosting_https_site} h ' > - . 'WHERE s.nid = h.nid ' > - . 'AND h.https_enabled IN(:https) ' > - . 'AND s.status = :enabled', array( > - ':https' => array(HOSTING_HTTPS_ENABLED, HOSTING_HTTPS_REQUIRED), > - ':enabled' => HOSTING_SITE_ENABLED, > - ))) { > - while ($row = $result->fetch()) { > - $sites[] = $row->nid; > - } > + $https = array(HOSTING_HTTPS_ENABLED, HOSTING_HTTPS_REQUIRED); > + $enabled = HOSTING_SITE_ENABLED; > + > + $query = db_select('hosting_site', 's'); > + $query->join('hosting_https_site', 'h', 's.nid = h.nid'); > + $query->fields('s', array('nid')) > + ->condition('h.https_enabled', $https, 'IN') > + ->condition('s.status', $enabled) > + ->orderBy('s.verified', 'ASC'); 42,43c61 < + // Only sites not verified in the last month should be checked. < + $where_extra .= ' AND s.verified <= :time '; --- > + $query->condition('s.verified', time() - (86400 * 7 * 4), '<='); 45d62 < + $limit_extra = ''; 47c64 < + $limit_extra .= ' LIMIT :count '; --- > + $query->range(0, $limit); 50,63c67,73 < if ($result = db_query('SELECT s.nid ' < . 'FROM {hosting_site} s, {hosting_https_site} h ' < . 'WHERE s.nid = h.nid ' < . 'AND h.https_enabled IN(:https) ' < - . 'AND s.status = :enabled', array( < + . 'AND s.status = :enabled' . $where_extra < + . 'ORDER BY s.verified ASC' . $limit_extra, array( < ':https' => array(HOSTING_HTTPS_ENABLED, HOSTING_HTTPS_REQUIRED), < ':enabled' => HOSTING_SITE_ENABLED, < + ':time' => time() - (86400 * 7 * 4), < + ':count' => $limit, < ))) { < while ($row = $result->fetch()) { < $sites[] = $row->nid; --- > + $result = $query->execute()->fetchAll(); > + > + foreach ($result as $item) { > + $sites[] = $item->nid; > } > > return $sites;