// Note: we don't care about char data in collection because there should be none
/**
* Finds an update
*
* @param array $options Options to use: update_site_id: the unique ID of the update site to look at
*
* @return array|boolean Update_sites and updates discovered. False on failure
*
* @since 1.7.0
*/
public function findUpdate($options)
{
$response = $this->getUpdateSiteResponse($options);
if ($response === false) {
return false;
}
$this->xmlParser = xml_parser_create('');
xml_set_object($this->xmlParser, $this);
xml_set_element_handler($this->xmlParser, '_startElement', '_endElement');
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_COLLECTION_PARSE_URL', $this->_url), 'warning');
return false;
}
// @todo: Decrement the bad counter if non-zero
return array('update_sites' => $this->update_sites, 'updates' => $this->updates);
}