cvs: pear-core /PEAR/Command Channels.php
| From: | Greg Beaver | Date: | Wed, 15 Dec 2004 02:56:36 +0000 |
| Subject: | cvs: pear-core /PEAR/Command Channels.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-cvs+get-27413@lists.php.net to get a copy of this message | ||
cellog Tue Dec 14 21:56:36 2004 EDT
Modified files:
/pear-core/PEAR/Command Channels.php
Log:
fix error detection if local alias is not a valid alias
http://cvs.php.net/diff.php/pear-core/PEAR/Command/Channels.php?r1=1.24&r2=1.25&ty=u
Index: pear-core/PEAR/Command/Channels.php
diff -u pear-core/PEAR/Command/Channels.php:1.24 pear-core/PEAR/Command/Channels.php:1.25
--- pear-core/PEAR/Command/Channels.php:1.24 Tue Dec 14 21:19:07 2004
+++ pear-core/PEAR/Command/Channels.php Tue Dec 14 21:56:36 2004
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Channels.php,v 1.24 2004/12/15 02:19:07 cellog Exp $
+// $Id: Channels.php,v 1.25 2004/12/15 02:56:36 cellog Exp $
require_once 'PEAR/Command/Common.php';
require_once 'PEAR/Registry.php';
@@ -638,13 +638,38 @@
{
$reg = &$this->config->getRegistry();
if (sizeof($params) == 1) {
- return $this->raiseError("No channel alias specified");
+ return $this->raiseError('No channel alias specified');
}
if (sizeof($params) != 2) {
return $this->raiseError(
- "Invalid format, correct is: channel-alias channel alias");
+ 'Invalid format, correct is: channel-alias channel alias');
}
-
+ if (!$reg->channelExists($params[0], true)) {
+ if ($reg->isAlias($params[0])) {
+ $extra = ' (use "channel-alias ' . $reg->channelName($params[0])
. ' ' .
+ strtolower($params[1]) . '")';
+ } else {
+ $extra = '';
+ }
+ return $this->raiseError('"' . $params[0] . '" is not a
valid channel' . $extra);
+ }
+ if ($reg->isAlias($params[1])) {
+ return $this->raiseError('Channel "' .
$reg->channelName($params[1]) . '" is ' .
+ 'already aliased to "' . strtolower($params[1]) . '",
cannot re-alias');
+ }
+ $chan = &$reg->getChannel($params[0]);
+ if (!$chan) {
+ return $this->raiseError('Corrupt registry? Error retrieving channel
"' . $params[0] .
+ '" information');
+ }
+ // make it a local alias
+ if (!$chan->setAlias(strtolower($params[1]), true)) {
+ return $this->raiseError('Alias "' . strtolower($params[1]) .
+ '" is not a valid channel alias');
+ }
+ $reg->updateChannel($chan);
+ $this->ui->outputData('Channel "' . $chan->getName() . '"
aliased successfully to "' .
+ strtolower($params[1]) . '"');
}
function doDiscover($command, $options, $params)