FOF30\Update\Update::removeObsoleteUpdateSites PHP Method

removeObsoleteUpdateSites() public method

Removes any update sites which go by the same name or the same location as our update site but do not match the extension ID.
    public function removeObsoleteUpdateSites()
    {
        $db = $this->container->db;
        // Get update site IDs
        $updateSiteIDs = $this->getUpdateSiteIds();
        // Find update sites where the name OR the location matches BUT they are not one of the update site IDs
        $query = $db->getQuery(true)->select($db->qn('update_site_id'))->from($db->qn('#__update_sites'))->where('((' . $db->qn('name') . ' = ' . $db->q($this->updateSiteName) . ') OR ' . '(' . $db->qn('location') . ' = ' . $db->q($this->updateSite) . '))');
        if (!empty($updateSiteIDs)) {
            $updateSitesQuoted = array_map(array($db, 'quote'), $updateSiteIDs);
            $query->where($db->qn('update_site_id') . ' NOT IN (' . implode(',', $updateSitesQuoted) . ')');
        }
        try {
            $ids = $db->setQuery($query)->loadColumn();
            if (!empty($ids)) {
                $obsoleteIDsQuoted = array_map(array($db, 'quote'), $ids);
                // Delete update sites
                $query = $db->getQuery(true)->delete('#__update_sites')->where($db->qn('update_site_id') . ' IN (' . implode(',', $obsoleteIDsQuoted) . ')');
                $db->setQuery($query)->execute();
                // Delete update sites to extension ID records
                $query = $db->getQuery(true)->delete('#__update_sites_extensions')->where($db->qn('update_site_id') . ' IN (' . implode(',', $obsoleteIDsQuoted) . ')');
                $db->setQuery($query)->execute();
            }
        } catch (\Exception $e) {
            // Do nothing on failure
            return;
        }
    }