Fix PEAR repository
parent
f98bd971f2
commit
e4cce193cf
|
@ -12,8 +12,10 @@
|
||||||
|
|
||||||
namespace Composer\Repository;
|
namespace Composer\Repository;
|
||||||
|
|
||||||
|
use Composer\IO\IOInterface;
|
||||||
use Composer\Package\Loader\ArrayLoader;
|
use Composer\Package\Loader\ArrayLoader;
|
||||||
use Composer\Util\RemoteFilesystem;
|
use Composer\Util\RemoteFilesystem;
|
||||||
|
use Composer\Downloader\TransportException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||||
|
@ -23,6 +25,7 @@ class PearRepository extends ArrayRepository
|
||||||
{
|
{
|
||||||
private $url;
|
private $url;
|
||||||
private $channel;
|
private $channel;
|
||||||
|
private $io;
|
||||||
private $rfs;
|
private $rfs;
|
||||||
|
|
||||||
public function __construct(array $config, IOInterface $io, RemoteFilesystem $rfs = null)
|
public function __construct(array $config, IOInterface $io, RemoteFilesystem $rfs = null)
|
||||||
|
@ -37,18 +40,16 @@ class PearRepository extends ArrayRepository
|
||||||
|
|
||||||
$this->url = rtrim($config['url'], '/');
|
$this->url = rtrim($config['url'], '/');
|
||||||
$this->channel = !empty($config['channel']) ? $config['channel'] : null;
|
$this->channel = !empty($config['channel']) ? $config['channel'] : null;
|
||||||
$this->rfs = $rfs ?: new RemoteFilesystem($io);
|
$this->io = $io;
|
||||||
|
$this->rfs = $rfs ?: new RemoteFilesystem($this->io);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initialize()
|
protected function initialize()
|
||||||
{
|
{
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
|
|
||||||
set_error_handler(function($severity, $message, $file, $line) {
|
$this->io->write('Initializing PEAR repository '.$this->url);
|
||||||
throw new \ErrorException($message, $severity, $severity, $file, $line);
|
|
||||||
});
|
|
||||||
$this->fetchFromServer();
|
$this->fetchFromServer();
|
||||||
restore_error_handler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fetchFromServer()
|
protected function fetchFromServer()
|
||||||
|
@ -67,7 +68,7 @@ class PearRepository extends ArrayRepository
|
||||||
try {
|
try {
|
||||||
$packagesLink = str_replace("info.xml", "packagesinfo.xml", $link);
|
$packagesLink = str_replace("info.xml", "packagesinfo.xml", $link);
|
||||||
$this->fetchPear2Packages($this->url . $packagesLink);
|
$this->fetchPear2Packages($this->url . $packagesLink);
|
||||||
} catch (\ErrorException $e) {
|
} catch (TransportException $e) {
|
||||||
if (false === strpos($e->getMessage(), '404')) {
|
if (false === strpos($e->getMessage(), '404')) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +81,7 @@ class PearRepository extends ArrayRepository
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $categoryLink
|
* @param string $categoryLink
|
||||||
* @throws ErrorException
|
* @throws TransportException
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function fetchPearPackages($categoryLink)
|
private function fetchPearPackages($categoryLink)
|
||||||
|
@ -98,7 +99,7 @@ class PearRepository extends ArrayRepository
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$releasesXML = $this->requestXml($allReleasesLink);
|
$releasesXML = $this->requestXml($allReleasesLink);
|
||||||
} catch (\ErrorException $e) {
|
} catch (TransportException $e) {
|
||||||
if (strpos($e->getMessage(), '404')) {
|
if (strpos($e->getMessage(), '404')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +121,7 @@ class PearRepository extends ArrayRepository
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$deps = $this->rfs->getContents($this->url, $releaseLink . "/deps.".$pearVersion.".txt", false);
|
$deps = $this->rfs->getContents($this->url, $releaseLink . "/deps.".$pearVersion.".txt", false);
|
||||||
} catch (\ErrorException $e) {
|
} catch (TransportException $e) {
|
||||||
if (strpos($e->getMessage(), '404')) {
|
if (strpos($e->getMessage(), '404')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -225,6 +226,7 @@ class PearRepository extends ArrayRepository
|
||||||
{
|
{
|
||||||
$loader = new ArrayLoader();
|
$loader = new ArrayLoader();
|
||||||
$packagesXml = $this->requestXml($packagesLink);
|
$packagesXml = $this->requestXml($packagesLink);
|
||||||
|
|
||||||
$informations = $packagesXml->getElementsByTagName('pi');
|
$informations = $packagesXml->getElementsByTagName('pi');
|
||||||
foreach ($informations as $information) {
|
foreach ($informations as $information) {
|
||||||
$package = $information->getElementsByTagName('p')->item(0);
|
$package = $information->getElementsByTagName('p')->item(0);
|
||||||
|
|
Loading…
Reference in New Issue