Update to PEAR 1.7.2, Image_Canvas 0.3.1, Image_Color 1.0.3, Image_Graph 0.7.2, XML_Parser 1.3.1.
Removed PHP_Compat, and references to it. Removed ionCube/Zend/mmCache compatibility checks in test.php script. Changed minimum PHP requirement to 5.0 in test.php script.
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Remote.php,v 1.86 2005/11/14 14:11:05 cellog Exp $
|
||||
* @version CVS: $Id: Remote.php,v 1.107 2008/04/11 01:16:40 dufuz Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
@@ -35,9 +35,9 @@ require_once 'PEAR/REST.php';
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2005 The PHP Group
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.4.5
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
@@ -58,7 +58,12 @@ Get details on a package from the server.',
|
||||
'summary' => 'List Available Upgrades',
|
||||
'function' => 'doListUpgrades',
|
||||
'shortcut' => 'lu',
|
||||
'options' => array(),
|
||||
'options' => array(
|
||||
'channelinfo' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'output fully channel-aware data, even on failure',
|
||||
),
|
||||
),
|
||||
'doc' => '[preferred_state]
|
||||
List releases on the server of packages you have installed where
|
||||
a newer version is available with the same release state (stable etc.)
|
||||
@@ -90,7 +95,15 @@ latest stable release of each package.',
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'specify a channel other than the default channel',
|
||||
'arg' => 'CHAN',
|
||||
)
|
||||
),
|
||||
'allchannels' => array(
|
||||
'shortopt' => 'a',
|
||||
'doc' => 'search packages from all known channels',
|
||||
),
|
||||
'channelinfo' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'output fully channel-aware data, even on failure',
|
||||
),
|
||||
),
|
||||
'doc' => '[packagename] [packageinfo]
|
||||
Lists all packages which match the search parameters. The first
|
||||
@@ -108,7 +121,11 @@ will be used to match any portion of the summary/description',
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'specify a channel other than the default channel',
|
||||
'arg' => 'CHAN',
|
||||
)
|
||||
),
|
||||
'channelinfo' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'output fully channel-aware data, even on failure',
|
||||
),
|
||||
),
|
||||
'doc' => '
|
||||
Lists the packages available on the configured server along with the
|
||||
@@ -158,8 +175,17 @@ parameter.
|
||||
|
||||
function _checkChannelForStatus($channel, $chan)
|
||||
{
|
||||
if (PEAR::isError($chan)) {
|
||||
$this->raiseError($chan);
|
||||
}
|
||||
if (!is_a($chan, 'PEAR_ChannelFile')) {
|
||||
return $this->raiseError('Internal corruption error: invalid channel "' .
|
||||
$channel . '"');
|
||||
}
|
||||
$rest = new PEAR_REST($this->config);
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$mirror = $this->config->get('preferred_mirror', null,
|
||||
$channel);
|
||||
$a = $rest->downloadHttp('http://' . $channel .
|
||||
'/channel.xml', $chan->lastModified());
|
||||
PEAR::staticPopErrorHandling();
|
||||
@@ -184,15 +210,17 @@ parameter.
|
||||
if (PEAR::isError($parsed)) {
|
||||
return $this->raiseError('Invalid package name "' . $package . '"');
|
||||
}
|
||||
|
||||
|
||||
$channel = $parsed['channel'];
|
||||
$this->config->set('default_channel', $channel);
|
||||
$chan = $reg->getChannel($channel);
|
||||
$this->_checkChannelForStatus($channel, $chan);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
$info = $rest->packageInfo($base, $parsed['package']);
|
||||
$info = $rest->packageInfo($base, $parsed['package'], $channel);
|
||||
} else {
|
||||
$r = &$this->config->getRemote();
|
||||
$info = $r->call('package.info', $parsed['package']);
|
||||
@@ -233,7 +261,9 @@ parameter.
|
||||
}
|
||||
}
|
||||
$chan = $reg->getChannel($channel);
|
||||
$this->_checkChannelForStatus($channel, $chan);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
$list_options = false;
|
||||
if ($this->config->get('preferred_state') == 'stable') {
|
||||
$list_options = true;
|
||||
@@ -242,11 +272,11 @@ parameter.
|
||||
$base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) {
|
||||
// use faster list-all if available
|
||||
$rest = &$this->config->getREST('1.1', array());
|
||||
$available = $rest->listAll($base, $list_options);
|
||||
$available = $rest->listAll($base, $list_options, true, false, false, $chan->getName());
|
||||
} elseif ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
$available = $rest->listAll($base, $list_options);
|
||||
$available = $rest->listAll($base, $list_options, true, false, false, $chan->getName());
|
||||
} else {
|
||||
$r = &$this->config->getRemote();
|
||||
if ($channel == 'pear.php.net') {
|
||||
@@ -265,6 +295,7 @@ parameter.
|
||||
'caption' => 'Channel ' . $channel . ' Available packages:',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Version'),
|
||||
'channel' => $channel
|
||||
);
|
||||
if (count($available)==0) {
|
||||
$data = '(no packages available yet)';
|
||||
@@ -299,16 +330,18 @@ parameter.
|
||||
$list_options = true;
|
||||
}
|
||||
$chan = $reg->getChannel($channel);
|
||||
$this->_checkChannelForStatus($channel, $chan);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) {
|
||||
// use faster list-all if available
|
||||
$rest = &$this->config->getREST('1.1', array());
|
||||
$available = $rest->listAll($base, $list_options, false);
|
||||
$available = $rest->listAll($base, $list_options, false, false, false, $chan->getName());
|
||||
} elseif ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
$available = $rest->listAll($base, $list_options, false);
|
||||
$available = $rest->listAll($base, $list_options, false, false, false, $chan->getName());
|
||||
} else {
|
||||
$r = &$this->config->getRemote();
|
||||
if ($channel == 'pear.php.net') {
|
||||
@@ -323,10 +356,17 @@ parameter.
|
||||
return $this->raiseError('The package list could not be fetched from the remote server. Please try again. (Debug info: "' . $available->getMessage() . '")');
|
||||
}
|
||||
$data = array(
|
||||
'caption' => 'All packages:',
|
||||
'caption' => 'All packages [Channel ' . $channel . ']:',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Latest', 'Local'),
|
||||
'channel' => $channel,
|
||||
);
|
||||
if (isset($options['channelinfo'])) {
|
||||
// add full channelinfo
|
||||
$data['caption'] = 'Channel ' . $channel . ' All packages:';
|
||||
$data['headline'] = array('Channel', 'Package', 'Latest', 'Local',
|
||||
'Description', 'Dependencies');
|
||||
}
|
||||
$local_pkgs = $reg->listPackages($channel);
|
||||
|
||||
foreach ($available as $name => $info) {
|
||||
@@ -360,13 +400,39 @@ parameter.
|
||||
if (isset($info['stable']) && !$info['stable']) {
|
||||
$info['stable'] = null;
|
||||
}
|
||||
$data['data'][$info['category']][] = array(
|
||||
$reg->channelAlias($channel) . '/' . $name,
|
||||
@$info['stable'],
|
||||
@$installed['version'],
|
||||
@$desc,
|
||||
@$info['deps'],
|
||||
|
||||
if (isset($options['channelinfo'])) {
|
||||
// add full channelinfo
|
||||
if ($info['stable'] === $info['unstable']) {
|
||||
$state = $info['state'];
|
||||
} else {
|
||||
$state = 'stable';
|
||||
}
|
||||
$latest = $info['stable'].' ('.$state.')';
|
||||
$local = '';
|
||||
if (isset($installed['version'])) {
|
||||
$inst_state = $reg->packageInfo($name, 'release_state', $channel);
|
||||
$local = $installed['version'].' ('.$inst_state.')';
|
||||
}
|
||||
|
||||
$packageinfo = array(
|
||||
$channel,
|
||||
$name,
|
||||
$latest,
|
||||
$local,
|
||||
isset($desc) ? $desc : null,
|
||||
isset($info['deps']) ? $info['deps'] : null,
|
||||
);
|
||||
} else {
|
||||
$packageinfo = array(
|
||||
$reg->channelAlias($channel) . '/' . $name,
|
||||
isset($info['stable']) ? $info['stable'] : null,
|
||||
isset($installed['version']) ? $installed['version'] : null,
|
||||
isset($desc) ? $desc : null,
|
||||
isset($info['deps']) ? $info['deps'] : null,
|
||||
);
|
||||
}
|
||||
$data['data'][$info['category']][] = $packageinfo;
|
||||
}
|
||||
|
||||
if (isset($options['mode']) && in_array($options['mode'], array('notinstalled', 'upgrades'))) {
|
||||
@@ -401,8 +467,33 @@ parameter.
|
||||
return $this->raiseError('no valid search string supplied');
|
||||
};
|
||||
|
||||
$savechannel = $channel = $this->config->get('default_channel');
|
||||
$channelinfo = isset($options['channelinfo']);
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (isset($options['allchannels'])) {
|
||||
// search all channels
|
||||
unset($options['allchannels']);
|
||||
$channels = $reg->getChannels();
|
||||
$errors = array();
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
foreach ($channels as $channel) {
|
||||
if ($channel->getName() != '__uri') {
|
||||
$options['channel'] = $channel->getName();
|
||||
$ret = $this->doSearch($command, $options, $params);
|
||||
if (PEAR::isError($ret)) {
|
||||
$errors[] = $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (count($errors) !== 0) {
|
||||
// for now, only give first error
|
||||
return PEAR::raiseError($errors[0]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$savechannel = $channel = $this->config->get('default_channel');
|
||||
$package = $params[0];
|
||||
$summary = isset($params[1]) ? $params[1] : false;
|
||||
if (isset($options['channel'])) {
|
||||
@@ -415,50 +506,85 @@ parameter.
|
||||
}
|
||||
}
|
||||
$chan = $reg->getChannel($channel);
|
||||
$this->_checkChannelForStatus($channel, $chan);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
$available = $rest->listAll($base, false, false, $package, $summary);
|
||||
$available = $rest->listAll($base, false, false, $package, $summary, $chan->getName());
|
||||
} else {
|
||||
$r = &$this->config->getRemote();
|
||||
$available = $r->call('package.search', $package, $summary, true,
|
||||
$available = $r->call('package.search', $package, $summary, true,
|
||||
$this->config->get('preferred_state') == 'stable', true);
|
||||
}
|
||||
if (PEAR::isError($available)) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return $this->raiseError($available);
|
||||
}
|
||||
if (!$available) {
|
||||
return $this->raiseError('no packages found that match pattern "' . $package . '"');
|
||||
if (!$available && !$channelinfo) {
|
||||
// clean exit when not found, no error !
|
||||
$data = 'no packages found that match pattern "' . $package . '", for channel '.$channel.'.';
|
||||
$this->ui->outputData($data);
|
||||
$this->config->set('default_channel', $channel);
|
||||
return true;
|
||||
}
|
||||
if ($channelinfo) {
|
||||
$data = array(
|
||||
'caption' => 'Matched packages, channel ' . $channel . ':',
|
||||
'border' => true,
|
||||
'headline' => array('Channel', 'Package', 'Stable/(Latest)', 'Local'),
|
||||
'channel' => $channel
|
||||
);
|
||||
} else {
|
||||
$data = array(
|
||||
'caption' => 'Matched packages, channel ' . $channel . ':',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Stable/(Latest)', 'Local'),
|
||||
'channel' => $channel
|
||||
);
|
||||
}
|
||||
$data = array(
|
||||
'caption' => 'Matched packages, channel ' . $channel . ':',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Stable/(Latest)', 'Local'),
|
||||
);
|
||||
|
||||
if (!$available && $channelinfo) {
|
||||
unset($data['headline']);
|
||||
$data['data'] = 'No packages found that match pattern "' . $package . '".';
|
||||
$available = array();
|
||||
}
|
||||
foreach ($available as $name => $info) {
|
||||
$installed = $reg->packageInfo($name, null, $channel);
|
||||
$desc = $info['summary'];
|
||||
if (isset($params[$name]))
|
||||
$desc .= "\n\n".$info['description'];
|
||||
|
||||
$unstable = '';
|
||||
if ($info['unstable']) {
|
||||
$unstable = '/(' . $info['unstable'] . ' ' . $info['state'] . ')';
|
||||
}
|
||||
if (!isset($info['stable']) || !$info['stable']) {
|
||||
$info['stable'] = 'none';
|
||||
$version_remote = 'none';
|
||||
} else {
|
||||
if ($info['unstable']) {
|
||||
$version_remote = $info['unstable'];
|
||||
} else {
|
||||
$version_remote = $info['stable'];
|
||||
}
|
||||
$version_remote .= ' ('.$info['state'].')';
|
||||
}
|
||||
$version = is_array($installed['version']) ? $installed['version']['release'] :
|
||||
$installed['version'];
|
||||
$data['data'][$info['category']][] = array(
|
||||
$name,
|
||||
$info['stable'] . $unstable,
|
||||
$version,
|
||||
$desc,
|
||||
if ($channelinfo) {
|
||||
$packageinfo = array(
|
||||
$channel,
|
||||
$name,
|
||||
$version_remote,
|
||||
$version,
|
||||
$desc,
|
||||
);
|
||||
} else {
|
||||
$packageinfo = array(
|
||||
$name,
|
||||
$version_remote,
|
||||
$version,
|
||||
$desc,
|
||||
);
|
||||
}
|
||||
$data['data'][$info['category']][] = $packageinfo;
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
$this->config->set('default_channel', $channel);
|
||||
@@ -480,8 +606,20 @@ parameter.
|
||||
{
|
||||
// make certain that dependencies are ignored
|
||||
$options['downloadonly'] = 1;
|
||||
|
||||
// eliminate error messages for preferred_state-related errors
|
||||
/* TODO: Should be an option, but until now download does respect
|
||||
prefered state */
|
||||
/* $options['ignorepreferred_state'] = 1; */
|
||||
// eliminate error messages for preferred_state-related errors
|
||||
|
||||
$downloader = &$this->getDownloader($options);
|
||||
$downloader->setDownloadDir(getcwd());
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$e = $downloader->setDownloadDir(getcwd());
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($e)) {
|
||||
return $this->raiseError('Current directory is not writeable, cannot download');
|
||||
}
|
||||
$errors = array();
|
||||
$downloaded = array();
|
||||
$err = $downloader->download($params);
|
||||
@@ -490,10 +628,9 @@ parameter.
|
||||
}
|
||||
$errors = $downloader->getErrorMsgs();
|
||||
if (count($errors)) {
|
||||
$errinfo = array();
|
||||
$errinfo['data'] = array($errors);
|
||||
$errinfo['headline'] = 'Download Errors';
|
||||
$this->ui->outputData($errinfo);
|
||||
foreach ($errors as $error) {
|
||||
$this->ui->outputData($error);
|
||||
}
|
||||
return $this->raiseError("$command failed");
|
||||
}
|
||||
$downloaded = $downloader->getDownloadedPackages();
|
||||
@@ -516,6 +653,9 @@ parameter.
|
||||
function doListUpgrades($command, $options, $params)
|
||||
{
|
||||
require_once 'PEAR/Common.php';
|
||||
if (isset($params[0]) && !is_array(PEAR_Common::betterStates($params[0]))) {
|
||||
return $this->raiseError($params[0] . ' is not a valid state (stable/beta/alpha/devel/etc.) try "pear help list-upgrades"');
|
||||
}
|
||||
$savechannel = $channel = $this->config->get('default_channel');
|
||||
$reg = &$this->config->getRegistry();
|
||||
foreach ($reg->listChannels() as $channel) {
|
||||
@@ -534,7 +674,9 @@ parameter.
|
||||
}
|
||||
$caption = $channel . ' Available Upgrades';
|
||||
$chan = $reg->getChannel($channel);
|
||||
$this->_checkChannelForStatus($channel, $chan);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
@@ -570,6 +712,7 @@ parameter.
|
||||
'caption' => $caption,
|
||||
'border' => 1,
|
||||
'headline' => array('Channel', 'Package', 'Local', 'Remote', 'Size'),
|
||||
'channel' => $channel
|
||||
);
|
||||
foreach ((array)$latest as $pkg => $info) {
|
||||
$package = strtolower($pkg);
|
||||
@@ -595,10 +738,22 @@ parameter.
|
||||
}
|
||||
$data['data'][] = array($channel, $pkg, "$inst_version ($inst_state)", "$version ($state)", $fs);
|
||||
}
|
||||
if (empty($data['data'])) {
|
||||
$this->ui->outputData('Channel ' . $channel . ': No upgrades available');
|
||||
} else {
|
||||
if (isset($options['channelinfo'])) {
|
||||
if (empty($data['data'])) {
|
||||
unset($data['headline']);
|
||||
if (count($inst) == 0) {
|
||||
$data['data'] = '(no packages installed)';
|
||||
} else {
|
||||
$data['data'] = '(no upgrades available)';
|
||||
}
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
} else {
|
||||
if (empty($data['data'])) {
|
||||
$this->ui->outputData('Channel ' . $channel . ': No upgrades available');
|
||||
} else {
|
||||
$this->ui->outputData($data, $command);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
@@ -613,6 +768,9 @@ parameter.
|
||||
$cache_dir = $this->config->get('cache_dir');
|
||||
$verbose = $this->config->get('verbose');
|
||||
$output = '';
|
||||
if (!file_exists($cache_dir) || !is_dir($cache_dir)) {
|
||||
return $this->raiseError("$cache_dir does not exist or is not a directory");
|
||||
}
|
||||
if (!($dp = @opendir($cache_dir))) {
|
||||
return $this->raiseError("opendir($cache_dir) failed: $php_errormsg");
|
||||
}
|
||||
@@ -621,17 +779,22 @@ parameter.
|
||||
}
|
||||
$num = 0;
|
||||
while ($ent = readdir($dp)) {
|
||||
if (preg_match('/^xmlrpc_cache_[a-z0-9]{32}$/', $ent) ||
|
||||
preg_match('/rest.cache(file|id)$/', $ent)) {
|
||||
if (preg_match('/^xmlrpc_cache_[a-z0-9]{32}\\z/', $ent) ||
|
||||
preg_match('/rest.cache(file|id)\\z/', $ent)) {
|
||||
$path = $cache_dir . DIRECTORY_SEPARATOR . $ent;
|
||||
$ok = @unlink($path);
|
||||
if (file_exists($path)) {
|
||||
$ok = @unlink($path);
|
||||
} else {
|
||||
$ok = false;
|
||||
$php_errormsg = '';
|
||||
}
|
||||
if ($ok) {
|
||||
if ($verbose >= 2) {
|
||||
$output .= "deleted $path\n";
|
||||
}
|
||||
$num++;
|
||||
} elseif ($verbose >= 1) {
|
||||
$output .= "failed to delete $path\n";
|
||||
$output .= "failed to delete $path $php_errormsg\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user