Back to ExtensionAdapter class

Method findUpdate

public array|bool
findUpdate
(mixed $options)
Finds an update.
Parameters
  • array $options Update options.
Returns
  • array|bool Array containing the array of update sites and array of updates. False on failure
Since
  • 1.7.0

Method findUpdate - Source code

/**
 * Finds an update.
 *
 * @param   array  $options  Update options.
 *
 * @return  array|boolean  Array containing the array of update sites and array of updates. False on failure
 *
 * @since   1.7.0
 */
public function findUpdate($options)
{
    $response = $this->getUpdateSiteResponse($options);
    if ($response === false) {
        return false;
    }
    if (\array_key_exists('minimum_stability', $options)) {
        $this->minimum_stability = $options['minimum_stability'];
    }
    $this->xmlParser = xml_parser_create('');
    xml_set_object($this->xmlParser, $this);
    xml_set_element_handler($this->xmlParser, '_startElement', '_endElement');
    xml_set_character_data_handler($this->xmlParser, '_characterData');
    if (!xml_parse($this->xmlParser, $response->body)) {
        // If the URL is missing the .xml extension, try appending it and retry loading the update
        if (!$this->appendExtension && substr($this->_url, -4) !== '.xml') {
            $options['append_extension'] = true;
            return $this->findUpdate($options);
        }
        $app = Factory::getApplication();
        $app->getLogger()->warning("Error parsing url: {$this->_url}", array('category' => 'updater'));
        $app->enqueueMessage(Text::sprintf('JLIB_UPDATER_ERROR_EXTENSION_PARSE_URL', $this->_url), 'warning');
        return false;
    }
    xml_parser_free($this->xmlParser);
    if (isset($this->latest)) {
        if (isset($this->latest->client) && \strlen($this->latest->client)) {
            $this->latest->client_id = ApplicationHelper::getClientInfo($this->latest->client, true)->id;
            unset($this->latest->client);
        }
        $updates = array($this->latest);
    } else {
        $updates = array();
    }
    return array('update_sites' => array(), 'updates' => $updates);
}