]> granicus.if.org Git - php/commitdiff
- Force params to version_compare() to be strings, otherwise some
authorTomas V.V.Cox <cox@php.net>
Wed, 19 Jun 2002 23:38:59 +0000 (23:38 +0000)
committerTomas V.V.Cox <cox@php.net>
Wed, 19 Jun 2002 23:38:59 +0000 (23:38 +0000)
  comparations will fail (ex. 0.9 will be equal to 0.90)
- Other minor cleanup's

pear/PEAR/Command/Install.php
pear/PEAR/Command/Registry.php
pear/PEAR/Command/Remote.php
pear/PEAR/Common.php
pear/PEAR/Config.php
pear/PEAR/Dependency.php
pear/PEAR/Frontend/CLI.php
pear/PEAR/Installer.php
pear/PEAR/Registry.php

index 6c24be19ad597ab4f08ff0f065176da786970e5c..36c0b80cd313e24c415e8e1ab519c5736a93bf91 100644 (file)
@@ -182,13 +182,16 @@ specified at once.
         if (empty($this->installer)) {
             $this->installer = &new PEAR_Installer($this->ui);
         }
+        if (sizeof($params) < 1) {
+            return $this->raiseError("Please supply the package(s) you want to uninstall");
+        }
         foreach ($params as $pkg) {
             if ($this->installer->uninstall($pkg, $options)) {
                 if ($this->config->get('verbose') > 0) {
-                    $this->ui->outputData("uninstall ok", $command);
+                    $this->ui->outputData("uninstall $pkg ok", $command);
                 }
             } else {
-                return $this->raiseError("uninstall failed");
+                return $this->raiseError("uninstall $pkg failed");
             }
         }
         return true;
index 57bc616544ac78303297ee036a067a42b65d7b53..95650befbb21f6f8215168ec3c485f83ff0cf311 100644 (file)
@@ -189,13 +189,13 @@ installed package.'
             // "pear shell-test Foo 1.0"
         } elseif (sizeof($params) == 2) {
             $v = $reg->packageInfo($params[0], 'version');
-            if (!$v || !version_compare($v, $params[1], "ge")) {
+            if (!$v || !version_compare("$v", "{$params[1]}", "ge")) {
                 exit(1);
             }
             // "pear shell-test Foo ge 1.0"
         } elseif (sizeof($params) == 3) {
             $v = $reg->packageInfo($params[0], 'version');
-            if (!$v || !version_compare($v, $params[2], $params[1])) {
+            if (!$v || !version_compare("$v", "{$params[2]}", $params[1])) {
                 exit(1);
             }
         } else {
index c92d6e36ccbcdeb88f401f43a3ab72e03ed73790..e373abb50a7209dd947015ef2311704f1d1e192b 100644 (file)
@@ -125,7 +125,7 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
         $info['installed'] = $installed['version'] ? $installed['version'] : '- no -';
 
         $this->ui->outputData($info, $command);
-        
+
         return true;
     }
 
@@ -190,7 +190,7 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
                     continue;
                 if ($options['mode'] == 'notinstalled' && isset($installed['version']))
                     continue;
-                if ($options['mode'] == 'upgrades' 
+                if ($options['mode'] == 'upgrades'
                     && (!isset($installed['version']) || $installed['version'] == $info['stable']))
                 {
                     continue;
@@ -329,7 +329,7 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
             }
             extract($info);
             $inst_version = $reg->packageInfo($package, 'version');
-            if (version_compare($version, $inst_version, "le")) {
+            if (version_compare("$version", "$inst_version", "le")) {
                 // installed version is up-to-date
                 continue;
             }
@@ -344,7 +344,11 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
             }
             $data['data'][] = array($package, $version, $fs);
         }
-        $this->ui->outputData($data, $command);
+        if (empty($data['data'])) {
+            $this->ui->outputData('No upgrades avaible');
+        } else {
+            $this->ui->outputData($data, $command);
+        }
         return true;
     }
 
index efd76f497ada39dbb5a10327387170478d2ac723..ca06a96fb118a7502653c57f155f41c3f2e4e28d 100644 (file)
@@ -974,11 +974,11 @@ class PEAR_Common extends PEAR
     function validatePackageInfo($info, &$errors, &$warnings)
     {
         global $_PEAR_Common_maintainer_roles,
-            $_PEAR_Common_release_states,
-            $_PEAR_Common_dependency_types,
-            $_PEAR_Common_dependency_relations,
-            $_PEAR_Common_file_roles,
-            $_PEAR_Common_replacement_types;
+               $_PEAR_Common_release_states,
+               $_PEAR_Common_dependency_types,
+               $_PEAR_Common_dependency_relations,
+               $_PEAR_Common_file_roles,
+               $_PEAR_Common_replacement_types;
         if (PEAR::isError($info = $this->infoFromAny($info))) {
             return $this->raiseError($info);
         }
index e62914041c48cb2820b3363d6a5ed63e85f864a4..321a2c5977f3714dd9c0e4b105f0e7ba12122ab4 100644 (file)
@@ -453,7 +453,7 @@ class PEAR_Config extends PEAR
             $version = $matches[1];
             $contents = substr($contents, strlen($matches[0]));
         }
-        if (version_compare($version, '1', '<')) {
+        if (version_compare("$version", '1', '<')) {
             $data = unserialize($contents);
             if (!is_array($data)) {
                 if (strlen(trim($contents)) > 0) {
@@ -601,7 +601,7 @@ class PEAR_Config extends PEAR
         }
         extract($this->configuration_info[$key]);
         switch ($type) {
-            case 'integer': 
+            case 'integer':
                 $value = (int)$value;
                 break;
             case 'set': {
index 38d2eb762edc5b7b01657b09e3d71fd063f9bd14..53b32c67e2cee70ffbb95ce000b614a34f276fc5 100644 (file)
@@ -112,7 +112,7 @@ class PEAR_Dependency
             case 'gt':
                 $version = $this->registry->packageInfo($name, 'version');
                 if (!$this->registry->packageExists($name)
-                    || !version_compare($version, $req, $relation))
+                    || !version_compare("$version", "$req", $relation))
                 {
                     return "requires package `$name' " .
                            $this->signOperator($relation) . " $req";
@@ -143,7 +143,8 @@ class PEAR_Dependency
         if (substr($relation, 0, 2) == 'v.') {
             $ext_ver = phpversion($name);
             $operator = substr($relation, 2);
-            if (!version_compare($ext_ver, $req, $operator)) {
+            // Force params to be strings, otherwise the comparation will fail (ex. 0.9==0.90)
+            if (!version_compare("$ext_ver", "$req", $operator)) {
                 return "'$name' PHP extension version " .
                         $this->signOperator($operator) . " $req is required";
             }
@@ -183,7 +184,7 @@ class PEAR_Dependency
         if (substr($relation, 0, 2) == 'v.') {
             $php_ver = phpversion();
             $operator = substr($relation, 2);
-            if (!version_compare($php_ver, $req, $operator)) {
+            if (!version_compare("$php_ver", "$req", $operator)) {
                 return "PHP version " . $this->signOperator($operator) .
                        " $req is required";
             }
index 33661387146f37b09601b8685f4092a9e52647ed..9a59ed7519b674c7c0eb506ba2afd68694c709cc 100644 (file)
@@ -422,7 +422,7 @@ class PEAR_Frontend_CLI extends PEAR
                     $count = count($data['data'][0]);
                     if ($count == 2) {
                         $opts = array(0 => array('wrap' => 25),
-                                      1 => array('wrap' => 50)
+                                      1 => array('wrap' => 48)
                         );
                     } elseif ($count == 3) {
                         $opts = array(0 => array('wrap' => 20),
index 2b6e43e2cb4e0b3464e6e5268a18b8a2ca7b9741..f1351c9473f698b4bcf208827b382b4c1bfb7b8c 100644 (file)
@@ -427,8 +427,8 @@ class PEAR_Installer extends PEAR_Common
             }
             $v1 = $this->registry->packageInfo($pkgname, 'version');
             $v2 = $pkginfo['version'];
-            $cmp = version_compare($v1, $v2, 'gt');
-            if (empty($options['force']) && !version_compare($v2, $v1, 'gt')) {
+            $cmp = version_compare("$v1", "$v2", 'gt');
+            if (empty($options['force']) && !version_compare("$v2", "$v1", 'gt')) {
                 return $this->raiseError("upgrade to a newer version ($v2 is not newer than $v1)");
             }
             if (empty($options['register-only'])) {
index 2d3028c69fe784a8149b8effee3453eee9e3bbb8..af222b8645a2de5306bb09836c6be4eb0913b44b 100644 (file)
@@ -561,7 +561,7 @@ class PEAR_Registry extends PEAR
                 // XXX (cox) Possible problem with changes in the way
                 // PEAR_Dependency::checkPackage() works
                 if ($relation != 'has') {
-                    if (!version_compare($new_version, $require, $relation)) {
+                    if (!version_compare("$new_version", "$require", $relation)) {
                         $fails[] = $dep;
                     }
                 }