From: Greg Beaver Date: Thu, 4 Dec 2003 01:22:50 +0000 (+0000) Subject: fix bugs found in unit-testing, one BC issue also X-Git-Tag: php-5.0.0b3RC1~355 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1558f748e3099cf6981aafc6525c717102f031a4;p=php fix bugs found in unit-testing, one BC issue also --- diff --git a/pear/PEAR/Downloader.php b/pear/PEAR/Downloader.php index 470b1864a8..70c69a01dc 100644 --- a/pear/PEAR/Downloader.php +++ b/pear/PEAR/Downloader.php @@ -294,16 +294,34 @@ class PEAR_Downloader extends PEAR_Common /** * Download any files and their dependencies, if necessary * + * BC-compatible method name * @param array a mixed list of package names, local files, or package.xml */ function download($packages) + { + return $this->doDownload($packages); + } + + // }}} + // {{{ doDownload() + + /** + * Download any files and their dependencies, if necessary + * + * @param array a mixed list of package names, local files, or package.xml + */ + function doDownload($packages) { $mywillinstall = array(); $state = $this->_preferredState; // {{{ download files in this list if necessary foreach($packages as $pkgfile) { + $need_download = false; if (!is_file($pkgfile)) { + if (preg_match('#^(http|ftp)://#', $pkgfile)) { + $need_download = true; + } $pkgfile = $this->_downloadNonFile($pkgfile); if (PEAR::isError($pkgfile)) { return $pkgfile; @@ -312,7 +330,11 @@ class PEAR_Downloader extends PEAR_Common continue; } } // end is_file() + $tempinfo = $this->infoFromAny($pkgfile); + if ($need_download) { + $this->_toDownload[] = $tempinfo['package']; + } if (isset($this->_options['alldeps']) || isset($this->_options['onlyreqdeps'])) { // ignore dependencies if there are any errors if (!PEAR::isError($tempinfo)) { @@ -349,17 +371,7 @@ class PEAR_Downloader extends PEAR_Common } if (count($deppackages)) { - // check dependencies' dependencies - // combine the list of packages to install - $temppack = array(); - foreach($this->_downloadedPackages as $p) { - $temppack[] = strtolower($p['info']['package']); - } - foreach($deppackages as $pack) { - $temppack[] = strtolower($pack); - } - $this->_toDownload = array_merge($this->_toDownload, $temppack); - $this->download($deppackages); + $this->doDownload($deppackages); } } // }}} if --alldeps or --onlyreqdeps } @@ -379,20 +391,7 @@ class PEAR_Downloader extends PEAR_Common $state = null; $pkgfile = $this->extractDownloadFileName($pkgfile, $version); if (preg_match('#^(http|ftp)://#', $pkgfile)) { - $pkgfile = $this->_downloadFile($pkgfile, $version, $origpkgfile); - if (PEAR::isError($pkgfile)) { - return $pkgfile; - } - $tempinfo = $this->infoFromAny($pkgfile); - if (isset($this->_options['alldeps']) || isset($this->_options['onlyreqdeps'])) { - // ignore dependencies if there are any errors - if (!PEAR::isError($tempinfo)) { - $mywillinstall[strtolower($tempinfo['package'])] = @$tempinfo['release_deps']; - } - } - $this->_downloadedPackages[] = array('pkg' => $tempinfo['package'], - 'file' => $pkgfile, 'info' => $tempinfo); - return false; + return $this->_downloadFile($pkgfile, $version, $origpkgfile); } if (!$this->validPackageName($pkgfile)) { return $this->raiseError("Package name '$pkgfile' not valid"); @@ -404,6 +403,9 @@ class PEAR_Downloader extends PEAR_Common $this->log(0, "Package '{$curinfo['package']}' already installed, skipping"); return false; } + if (in_array($pkgfile, $this->_toDownload)) { + return false; + } $releases = $this->_remote->call('package.info', $pkgfile, 'releases'); if (!count($releases)) { return $this->raiseError("No releases found for package '$pkgfile'"); @@ -460,6 +462,7 @@ class PEAR_Downloader extends PEAR_Common return false; } } + $this->_toDownload[] = $pkgfile; return $this->_downloadFile($pkgfile, $version, $origpkgfile, $state); }