cvs: pear-core /PEAR Downloader.php /PEAR/Downloader Package.php /tests/PEAR_Command_Remote/download test_fail.phpt /tests/PEAR_Downloader_Package
test_initialize_invaliddownloadurl.phpt
| From: | Greg Beaver | Date: | Sun, 26 Mar 2006 22:07:57 +0000 |
| Subject: | cvs: pear-core /PEAR Downloader.php /PEAR/Downloader Package.php /tests/PEAR_Command_Remote/download test_fail.phpt /tests/PEAR_Downloader_Package test_initialize_invaliddownloadurl.phpt |
||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-4657@lists.php.net to get a copy of this message | ||
cellog Sun Mar 26 22:07:57 2006 UTC
Modified files:
/pear-core/PEAR Downloader.php
/pear-core/PEAR/Downloader Package.php
/pear-core/tests/PEAR_Command_Remote/download test_fail.phpt
/pear-core/tests/PEAR_Downloader_Package
test_initialize_invaliddownloadurl.phpt
Log:
remove as many @ as possible
Add downloadHttp returns to error message of download
Update tests
http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Downloader.php?r1=1.99&r2=1.100&diff_format=u Index: pear-core/PEAR/Downloader.php diff -u pear-core/PEAR/Downloader.php:1.99 pear-core/PEAR/Downloader.php:1.100 --- pear-core/PEAR/Downloader.php:1.99 Thu Mar 2 18:14:13 2006 +++ pear-core/PEAR/Downloader.php Sun Mar 26 22:07:56 2006 @@ -18,7 +18,7 @@ * @author Martin Jansen <mj@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Downloader.php,v 1.99 2006/03/02 18:14:13 cellog Exp $ + * @version CVS: $Id: Downloader.php,v 1.100 2006/03/26 22:07:56 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.3.0 */ @@ -182,7 +182,8 @@ if (!count($unused)) { continue; } - @array_walk($this->_installed[$key], 'strtolower'); + $strtolower = create_function('$a','return strtolower($a);'); + array_walk($this->_installed[$key], $strtolower); } } } @@ -213,7 +214,7 @@ } $b = new PEAR_ChannelFile; if ($b->fromXmlFile($a)) { - @unlink($a); + unlink($a); if ($this->config->get('auto_discover')) { $this->_registry->addChannel($b, $lastmodified); $alias = $b->getName(); @@ -225,7 +226,7 @@ } return true; } - @unlink($a); + unlink($a); return false; } @@ -293,29 +294,31 @@ $this->pushError('Package "' . $param . '" is not valid', PEAR_INSTALLER_SKIPPED); } else { - if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && - !isset($this->_options['offline'])) { - $channelschecked[$params[$i]->getChannel()] = true; - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - if (!class_exists('System')) { - require_once 'System.php'; - } - $curchannel = &$this->_registry->getChannel($params[$i]->getChannel()); - if (PEAR::isError($curchannel)) { + do { + if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && + !isset($this->_options['offline'])) { + $channelschecked[$params[$i]->getChannel()] = true; + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + if (!class_exists('System')) { + require_once 'System.php'; + } + $curchannel = &$this->_registry->getChannel($params[$i]->getChannel()); + if (PEAR::isError($curchannel)) { + PEAR::staticPopErrorHandling(); + return $this->raiseError($curchannel); + } + $a = $this->downloadHttp('http://' . $params[$i]->getChannel() . + '/channel.xml', $this->ui, + System::mktemp(array('-d')), null, $curchannel->lastModified()); PEAR::staticPopErrorHandling(); - return $this->raiseError($curchannel); - } - $a = $this->downloadHttp('http://' . $params[$i]->getChannel() . - '/channel.xml', $this->ui, - System::mktemp(array('-d')), null, $curchannel->lastModified()); - PEAR::staticPopErrorHandling(); - if (PEAR::isError($a) || !$a) { - continue; + if (PEAR::isError($a) || !$a) { + break; + } + $this->log(0, 'WARNING: channel "' . $params[$i]->getChannel() . '" has ' . + 'updated its protocols, use "channel-update ' . $params[$i]->getChannel() . + '" to update'); } - $this->log(0, 'WARNING: channel "' . $params[$i]->getChannel() . '" has ' . - 'updated its protocols, use "channel-update ' . $params[$i]->getChannel() . - '" to update'); - } + } while (false); if ($params[$i] && !isset($this->_options['downloadonly'])) { if (isset($this->_options['packagingroot'])) { $checkdir = $this->_prependPath( @@ -331,7 +334,7 @@ if ($checkdir == '.') { $checkdir = '/'; } - if (!@is_writeable($checkdir)) { + if (!is_writeable($checkdir)) { return PEAR::raiseError('Cannot install, php_dir for channel "' . $params[$i]->getChannel() . '" is not writeable by the current user'); } @@ -1317,9 +1320,9 @@ if (!isset($info['host'])) { return PEAR::raiseError('Cannot download from non-URL "' . $url . '"'); } else { - $host = @$info['host']; - $port = @$info['port']; - $path = @$info['path']; + $host = isset($info['host']) ? $info['host'] : null; + $port = isset($info['port']) ? $info['port'] : null; + $path = isset($info['path']) ? $info['path'] : null; } if (isset($this)) { $config = &$this->config; @@ -1327,15 +1330,15 @@ $config = &PEAR_Config::singleton(); } $proxy_host = $proxy_port = $proxy_user = $proxy_pass = ''; - if ($config->get('http_proxy')&& + if ($config->get('http_proxy') && $proxy = parse_url($config->get('http_proxy'))) { - $proxy_host = @$proxy['host']; + $proxy_host = isset($proxy['host']) ? $proxy['host'] : null; if (isset($proxy['scheme']) && $proxy['scheme'] == 'https') { $proxy_host = 'ssl://' . $proxy_host; } - $proxy_port = @$proxy['port']; - $proxy_user = @$proxy['user']; - $proxy_pass = @$proxy['pass']; + $proxy_port = isset($proxy['port']) ? $proxy['port'] : null; + $proxy_user = isset($proxy['user']) ? $proxy['user'] : null; + $proxy_pass = isset($proxy['pass']) ? $proxy['pass'] : null; if ($proxy_port == '') { $proxy_port = 8080; @@ -1471,7 +1474,7 @@ if ($callback) { call_user_func($callback, 'start', array(basename($dest_file), $length)); } - while ($data = @fread($fp, 1024)) { + while ($data = fread($fp, 1024)) { $bytes += strlen($data); if ($callback) { call_user_func($callback, 'bytesread', $bytes); http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Downloader/Package.php?r1=1.91&r2=1.92&diff_format=u Index: pear-core/PEAR/Downloader/Package.php diff -u pear-core/PEAR/Downloader/Package.php:1.91 pear-core/PEAR/Downloader/Package.php:1.92 --- pear-core/PEAR/Downloader/Package.php:1.91 Mon Jan 23 19:05:52 2006 +++ pear-core/PEAR/Downloader/Package.php Sun Mar 26 22:07:56 2006 @@ -15,7 +15,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Package.php,v 1.91 2006/01/23 19:05:52 cellog Exp $ + * @version CVS: $Id: Package.php,v 1.92 2006/03/26 22:07:56 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.4.0a1 */ @@ -1384,7 +1384,7 @@ $saveparam = ", cannot download \"$saveparam\""; } $err = PEAR::raiseError('Could not download from "' . $param . - '"' . $saveparam); + '"' . $saveparam . ' (' . $file->getMessage() . ')'); return $err; } if ($this->_rawpackagefile) { http://cvs.php.net/viewcvs.cgi/pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt?r1=1.4&r2=1.5&diff_format=u Index: pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt diff -u pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt:1.4 pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt:1.5 --- pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt:1.4 Fri Feb 3 04:51:43 2006 +++ pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt Sun Mar 26 22:07:57 2006 @@ -19,7 +19,7 @@ 0 => array ( 0 => 0, - 1 => 'Could not download from "http://www.example.com/bloo.tgz"', + 1 => 'Could not download from "http://www.example.com/bloo.tgz" (File http://www.example.com:80/bloo.tgz not valid (received: HTTP/1.1 404 http://www.example.com/bloo.tgz Is not valid))', ), 1 => array ( http://cvs.php.net/viewcvs.cgi/pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt?r1=1.4&r2=1.5&diff_format=u Index: pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt diff -u pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt:1.4 pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt:1.5 --- pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt:1.4 Fri Feb 3 04:34:36 2006 +++ pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt Sun Mar 26 22:07:57 2006 @@ -17,7 +17,7 @@ $result = $dp->initialize('http://www.example.com/test-1.1.tgz'); $phpunit->assertErrors(array( array('package' => 'PEAR_Error', - 'message' => 'Could not download from "http://www.example.com/test-1.1.tgz"'), + 'message' => 'Could not download from "http://www.example.com/test-1.1.tgz" (File http://www.example.com:80/test-1.1.tgz not valid (received: HTTP/1.1 404 http://www.example.com/test-1.1.tgz Is not valid))'), array('package' => 'PEAR_Error', 'message' => 'Invalid or missing remote package file'), ), 'expected errors'); @@ -30,7 +30,7 @@ 1 => array ( 0 => 0, - 1 => 'Could not download from "http://www.example.com/test-1.1.tgz"', + 1 => 'Could not download from "http://www.example.com/test-1.1.tgz" (File http://www.example.com:80/test-1.1.tgz not valid (received: HTTP/1.1 404 http://www.example.com/test-1.1.tgz Is not valid))', ), ), $fakelog->getLog(), 'log messages'); $phpunit->assertEquals(array (
http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Downloader.php?r1=1.99&r2=1.100&diff_format=u Index: pear-core/PEAR/Downloader.php diff -u pear-core/PEAR/Downloader.php:1.99 pear-core/PEAR/Downloader.php:1.100 --- pear-core/PEAR/Downloader.php:1.99 Thu Mar 2 18:14:13 2006 +++ pear-core/PEAR/Downloader.php Sun Mar 26 22:07:56 2006 @@ -18,7 +18,7 @@ * @author Martin Jansen <mj@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Downloader.php,v 1.99 2006/03/02 18:14:13 cellog Exp $ + * @version CVS: $Id: Downloader.php,v 1.100 2006/03/26 22:07:56 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.3.0 */ @@ -182,7 +182,8 @@ if (!count($unused)) { continue; } - @array_walk($this->_installed[$key], 'strtolower'); + $strtolower = create_function('$a','return strtolower($a);'); + array_walk($this->_installed[$key], $strtolower); } } } @@ -213,7 +214,7 @@ } $b = new PEAR_ChannelFile; if ($b->fromXmlFile($a)) { - @unlink($a); + unlink($a); if ($this->config->get('auto_discover')) { $this->_registry->addChannel($b, $lastmodified); $alias = $b->getName(); @@ -225,7 +226,7 @@ } return true; } - @unlink($a); + unlink($a); return false; } @@ -293,29 +294,31 @@ $this->pushError('Package "' . $param . '" is not valid', PEAR_INSTALLER_SKIPPED); } else { - if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && - !isset($this->_options['offline'])) { - $channelschecked[$params[$i]->getChannel()] = true; - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - if (!class_exists('System')) { - require_once 'System.php'; - } - $curchannel = &$this->_registry->getChannel($params[$i]->getChannel()); - if (PEAR::isError($curchannel)) { + do { + if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && + !isset($this->_options['offline'])) { + $channelschecked[$params[$i]->getChannel()] = true; + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + if (!class_exists('System')) { + require_once 'System.php'; + } + $curchannel = &$this->_registry->getChannel($params[$i]->getChannel()); + if (PEAR::isError($curchannel)) { + PEAR::staticPopErrorHandling(); + return $this->raiseError($curchannel); + } + $a = $this->downloadHttp('http://' . $params[$i]->getChannel() . + '/channel.xml', $this->ui, + System::mktemp(array('-d')), null, $curchannel->lastModified()); PEAR::staticPopErrorHandling(); - return $this->raiseError($curchannel); - } - $a = $this->downloadHttp('http://' . $params[$i]->getChannel() . - '/channel.xml', $this->ui, - System::mktemp(array('-d')), null, $curchannel->lastModified()); - PEAR::staticPopErrorHandling(); - if (PEAR::isError($a) || !$a) { - continue; + if (PEAR::isError($a) || !$a) { + break; + } + $this->log(0, 'WARNING: channel "' . $params[$i]->getChannel() . '" has ' . + 'updated its protocols, use "channel-update ' . $params[$i]->getChannel() . + '" to update'); } - $this->log(0, 'WARNING: channel "' . $params[$i]->getChannel() . '" has ' . - 'updated its protocols, use "channel-update ' . $params[$i]->getChannel() . - '" to update'); - } + } while (false); if ($params[$i] && !isset($this->_options['downloadonly'])) { if (isset($this->_options['packagingroot'])) { $checkdir = $this->_prependPath( @@ -331,7 +334,7 @@ if ($checkdir == '.') { $checkdir = '/'; } - if (!@is_writeable($checkdir)) { + if (!is_writeable($checkdir)) { return PEAR::raiseError('Cannot install, php_dir for channel "' . $params[$i]->getChannel() . '" is not writeable by the current user'); } @@ -1317,9 +1320,9 @@ if (!isset($info['host'])) { return PEAR::raiseError('Cannot download from non-URL "' . $url . '"'); } else { - $host = @$info['host']; - $port = @$info['port']; - $path = @$info['path']; + $host = isset($info['host']) ? $info['host'] : null; + $port = isset($info['port']) ? $info['port'] : null; + $path = isset($info['path']) ? $info['path'] : null; } if (isset($this)) { $config = &$this->config; @@ -1327,15 +1330,15 @@ $config = &PEAR_Config::singleton(); } $proxy_host = $proxy_port = $proxy_user = $proxy_pass = ''; - if ($config->get('http_proxy')&& + if ($config->get('http_proxy') && $proxy = parse_url($config->get('http_proxy'))) { - $proxy_host = @$proxy['host']; + $proxy_host = isset($proxy['host']) ? $proxy['host'] : null; if (isset($proxy['scheme']) && $proxy['scheme'] == 'https') { $proxy_host = 'ssl://' . $proxy_host; } - $proxy_port = @$proxy['port']; - $proxy_user = @$proxy['user']; - $proxy_pass = @$proxy['pass']; + $proxy_port = isset($proxy['port']) ? $proxy['port'] : null; + $proxy_user = isset($proxy['user']) ? $proxy['user'] : null; + $proxy_pass = isset($proxy['pass']) ? $proxy['pass'] : null; if ($proxy_port == '') { $proxy_port = 8080; @@ -1471,7 +1474,7 @@ if ($callback) { call_user_func($callback, 'start', array(basename($dest_file), $length)); } - while ($data = @fread($fp, 1024)) { + while ($data = fread($fp, 1024)) { $bytes += strlen($data); if ($callback) { call_user_func($callback, 'bytesread', $bytes); http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Downloader/Package.php?r1=1.91&r2=1.92&diff_format=u Index: pear-core/PEAR/Downloader/Package.php diff -u pear-core/PEAR/Downloader/Package.php:1.91 pear-core/PEAR/Downloader/Package.php:1.92 --- pear-core/PEAR/Downloader/Package.php:1.91 Mon Jan 23 19:05:52 2006 +++ pear-core/PEAR/Downloader/Package.php Sun Mar 26 22:07:56 2006 @@ -15,7 +15,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Package.php,v 1.91 2006/01/23 19:05:52 cellog Exp $ + * @version CVS: $Id: Package.php,v 1.92 2006/03/26 22:07:56 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.4.0a1 */ @@ -1384,7 +1384,7 @@ $saveparam = ", cannot download \"$saveparam\""; } $err = PEAR::raiseError('Could not download from "' . $param . - '"' . $saveparam); + '"' . $saveparam . ' (' . $file->getMessage() . ')'); return $err; } if ($this->_rawpackagefile) { http://cvs.php.net/viewcvs.cgi/pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt?r1=1.4&r2=1.5&diff_format=u Index: pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt diff -u pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt:1.4 pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt:1.5 --- pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt:1.4 Fri Feb 3 04:51:43 2006 +++ pear-core/tests/PEAR_Command_Remote/download/test_fail.phpt Sun Mar 26 22:07:57 2006 @@ -19,7 +19,7 @@ 0 => array ( 0 => 0, - 1 => 'Could not download from "http://www.example.com/bloo.tgz"', + 1 => 'Could not download from "http://www.example.com/bloo.tgz" (File http://www.example.com:80/bloo.tgz not valid (received: HTTP/1.1 404 http://www.example.com/bloo.tgz Is not valid))', ), 1 => array ( http://cvs.php.net/viewcvs.cgi/pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt?r1=1.4&r2=1.5&diff_format=u Index: pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt diff -u pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt:1.4 pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt:1.5 --- pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt:1.4 Fri Feb 3 04:34:36 2006 +++ pear-core/tests/PEAR_Downloader_Package/test_initialize_invaliddownloadurl.phpt Sun Mar 26 22:07:57 2006 @@ -17,7 +17,7 @@ $result = $dp->initialize('http://www.example.com/test-1.1.tgz'); $phpunit->assertErrors(array( array('package' => 'PEAR_Error', - 'message' => 'Could not download from "http://www.example.com/test-1.1.tgz"'), + 'message' => 'Could not download from "http://www.example.com/test-1.1.tgz" (File http://www.example.com:80/test-1.1.tgz not valid (received: HTTP/1.1 404 http://www.example.com/test-1.1.tgz Is not valid))'), array('package' => 'PEAR_Error', 'message' => 'Invalid or missing remote package file'), ), 'expected errors'); @@ -30,7 +30,7 @@ 1 => array ( 0 => 0, - 1 => 'Could not download from "http://www.example.com/test-1.1.tgz"', + 1 => 'Could not download from "http://www.example.com/test-1.1.tgz" (File http://www.example.com:80/test-1.1.tgz not valid (received: HTTP/1.1 404 http://www.example.com/test-1.1.tgz Is not valid))', ), ), $fakelog->getLog(), 'log messages'); $phpunit->assertEquals(array (