1
0
Fork 0

Merge pull request #5071 from jdufresne/master

Prefer the first https:// PEAR mirror; avoid http://.
pull/5077/head
Jordi Boggiano 2016-03-16 08:47:37 +00:00
commit 7c62e2b534
1 changed files with 11 additions and 1 deletions

View File

@ -80,8 +80,18 @@ class ChannelReader extends BaseChannelReader
$channelXml->registerXPathNamespace('ns', self::CHANNEL_NS);
foreach ($supportedVersions as $version) {
$xpathTest = "ns:servers/ns:primary/ns:rest/ns:baseurl[@type='{$version}']";
$xpathTest = "ns:servers/ns:*/ns:rest/ns:baseurl[@type='{$version}']";
$testResult = $channelXml->xpath($xpathTest);
foreach ($testResult as $result) {
// Choose first https:// option.
$result = (string) $result;
if (preg_match('{^https://}i', $result)) {
return array('version' => $version, 'baseUrl' => $result);
}
}
// Fallback to non-https if it does not exist.
if (count($testResult) > 0) {
return array('version' => $version, 'baseUrl' => (string) $testResult[0]);
}