From baba5432c9a1aa7e0c9b12dde1cc2830db08054c Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Wed, 13 Aug 2003 21:16:31 +0000 Subject: [PATCH] fix uninstall for optional dependencies, bug #25080 --- pear/PEAR/Dependency.php | 9 +++++++-- pear/PEAR/Installer.php | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pear/PEAR/Dependency.php b/pear/PEAR/Dependency.php index 37afd71a36..370270aa71 100644 --- a/pear/PEAR/Dependency.php +++ b/pear/PEAR/Dependency.php @@ -151,11 +151,12 @@ class PEAR_Dependency * Check package dependencies on uninstall * * @param string $error The resultant error string + * @param string $warning The resultant warning string * @param string $name Name of the package to test * * @return bool true if there were errors */ - function checkPackageUninstall(&$error, $package) + function checkPackageUninstall(&$error, &$warning, $package) { $error = null; $packages = $this->registry->listPackages(); @@ -169,7 +170,11 @@ class PEAR_Dependency } foreach ($deps as $dep) { if ($dep['type'] == 'pkg' && strcasecmp($dep['name'], $package) == 0) { - $error .= "Package '$pkg' depends on '$package'\n"; + if (isset($dep['optional']) && $dep['optional'] == 'yes') { + $warning .= "\nWarning: Package '$pkg' optionally depends on '$package'"; + } else { + $error .= "Package '$pkg' depends on '$package'\n"; + } } } } diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 416fab9991..577973dff6 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -774,12 +774,19 @@ class PEAR_Installer extends PEAR_Common $this->installroot = ''; } $this->registry = &new PEAR_Registry($php_dir); + $filelist = $this->registry->packageInfo($package, 'filelist'); + if ($filelist == null) { + return $this->raiseError("$package not installed"); + } if (empty($options['nodeps'])) { $depchecker = &new PEAR_Dependency($this->registry); - $error = $depchecker->checkPackageUninstall($errors, $package); + $error = $depchecker->checkPackageUninstall($errors, $warning, $package); if ($error) { return $this->raiseError($errors . 'uninstall failed'); } + if ($warning) { + $this->log(0, $warning); + } } // Delete the files if (PEAR::isError($err = $this->_deletePackageFiles($package))) { -- 2.40.0