]> granicus.if.org Git - php/commitdiff
fix uninstall for optional dependencies, bug #25080
authorGreg Beaver <cellog@php.net>
Wed, 13 Aug 2003 21:16:31 +0000 (21:16 +0000)
committerGreg Beaver <cellog@php.net>
Wed, 13 Aug 2003 21:16:31 +0000 (21:16 +0000)
pear/PEAR/Dependency.php
pear/PEAR/Installer.php

index 37afd71a368c88db3a2b4580aa9af30e4ba3add3..370270aa713452c1c33465d7f253595f43b45f6d 100644 (file)
@@ -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";
+                    }
                 }
             }
         }
index 416fab9991b2cef3ae14c86fa34345ef0c0c7f6d..577973dff63559e552a6fd022b2931562941dac3 100644 (file)
@@ -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))) {