php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24845 spaces in pathname make PEAR fail
Submitted: 2003-07-28 17:57 UTC Modified: 2003-07-30 05:52 UTC
From: greg at chiaraquartet dot net Assigned:
Status: Closed Package: PEAR related
PHP Version: 4.3.2 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: greg at chiaraquartet dot net
New email:
PHP Version: OS:

 

 [2003-07-28 17:57 UTC] greg at chiaraquartet dot net
Description:
------------
As we all know, PEAR fails when there are spaces in the pathname.

This is an old bug.  However, I have good news: I have a patch that fixes this for all commands.  Here is a patch.  Note that this patch also applies new publicweb functionality to Config.php.  I'll generate a patch for all the changes I've made today.  I do have commit access, so if this patch looks good, I'll just commit the code.

Greg

P.S. this is quite exciting for me - PEAR has never worked properly with spaces, and now it will with no API change or BC problems

Index: pear/PEAR/Common.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Common.php,v
retrieving revision 1.93
diff -u -r1.93 Common.php
--- pear/PEAR/Common.php	12 Jul 2003 15:15:38 -0000	1.93
+++ pear/PEAR/Common.php	28 Jul 2003 22:50:10 -0000
@@ -63,7 +63,7 @@
  * Valid file roles
  * @var array
  */
-$GLOBALS['_PEAR_Common_file_roles'] = array('php','ext','test','doc','data','src','script');
+$GLOBALS['_PEAR_Common_file_roles'] = array('php','ext','test','doc','data','src','script','publicweb');
 
 /**
  * Valid replacement types
@@ -156,7 +156,12 @@
         $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
         while ($file = array_shift($tempfiles)) {
             if (@is_dir($file)) {
-                System::rm("-rf $file");
+                $options =
+                    array(
+                        '-rf',
+                        $file,
+                         );
+                System::rm($options);
             } elseif (file_exists($file)) {
                 unlink($file);
             }
@@ -198,7 +203,12 @@
     function mkDirHier($dir)
     {
         $this->log(2, "+ create dir $dir");
-        return System::mkDir("-p $dir");
+        $options =
+            array(
+                '-p',
+                $dir,
+                 );
+        return System::mkDir($options);
     }
 
     // }}}
@@ -242,11 +252,12 @@
     function mkTempDir($tmpdir = '')
     {
         if ($tmpdir) {
-            $topt = "-t $tmpdir ";
+            $topt = array('-t', $tmpdir);
         } else {
-            $topt = '';
+            $topt = array();
         }
-        if (!$tmpdir = System::mktemp($topt . '-d pear')) {
+        $topt = array_merge($topt, array('-d', 'pear'));
+        if (!$tmpdir = System::mktemp($topt)) {
             return false;
         }
         $this->addTempFile($tmpdir);
Index: pear/PEAR/Config.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Config.php,v
retrieving revision 1.48
diff -u -r1.48 Config.php
--- pear/PEAR/Config.php	3 Jul 2003 06:43:31 -0000	1.48
+++ pear/PEAR/Config.php	28 Jul 2003 22:50:11 -0000
@@ -112,6 +112,15 @@
            $PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'data');
 }
 
+// Default for publicweb dir
+if (getenv('PHP_PEAR_PUBLICWEB_DIR')) {
+    define('PEAR_CONFIG_DEFAULT_PUBLICWEB_DIR', getenv('PHP_PEAR_PUBLICWEB_DIR'));
+} else {
+    // use the data directory if no publicweb option is defined
+    define('PEAR_CONFIG_DEFAULT_PUBLICWEB_DIR',
+           PEAR_CONFIG_DEFAULT_DATA_DIR);
+}
+
 // Default for test_dir
 if (getenv('PHP_PEAR_TEST_DIR')) {
     define('PEAR_CONFIG_DEFAULT_TEST_DIR', getenv('PHP_PEAR_TEST_DIR'));
@@ -279,6 +288,13 @@
             'prompt' => 'PEAR executables directory',
             'group' => 'File Locations',
             ),
+        'publicweb_dir' => array(
+            'type' => 'directory',
+            'default' => PEAR_CONFIG_DEFAULT_PUBLICWEB_DIR,
+            'doc' => 'sub-directory of http doc root where public html-related files are installed',
+            'prompt' => 'PEAR html-files directory',
+            'group' => 'File Locations',
+            ),
         'data_dir' => array(
             'type' => 'directory',
             'default' => PEAR_CONFIG_DEFAULT_DATA_DIR,
@@ -577,7 +593,8 @@
         }
         $data = ($data === null) ? $this->configuration[$layer] : $data;
         $this->_encodeOutput($data);
-        if (!@System::mkDir("-p " . dirname($file))) {
+        $opt = array('-p', dirname($file));
+        if (!@System::mkDir($opt)) {
             return $this->raiseError("could not create directory: " . dirname($file));
         }
         if (@is_file($file) && !@is_writeable($file)) {
Index: pear/PEAR/Installer.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Installer.php,v
retrieving revision 1.92
diff -u -r1.92 Installer.php
--- pear/PEAR/Installer.php	8 Jul 2003 10:33:38 -0000	1.92
+++ pear/PEAR/Installer.php	28 Jul 2003 22:50:11 -0000
@@ -180,6 +180,7 @@
                 break;
             case 'ext':
             case 'php':
+            case 'publicweb':
                 $dest_dir = $this->config->get($atts['role'] . '_dir');
                 break;
             case 'script':
Index: pear/PEAR/Packager.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Packager.php,v
retrieving revision 1.48
diff -u -r1.48 Packager.php
--- pear/PEAR/Packager.php	27 Jun 2003 10:46:53 -0000	1.48
+++ pear/PEAR/Packager.php	28 Jul 2003 22:50:12 -0000
@@ -116,7 +116,13 @@
             chdir($oldcwd);
             return $this->raiseError($new_xml);
         }
-        if (!($tmpdir = System::mktemp('-t '.getcwd().' -d'))) {
+        $opt =
+            array(
+                '-t',
+                getcwd(),
+                '-d',
+                 );
+        if (!($tmpdir = System::mktemp($opt))) {
             chdir($oldcwd);
             return $this->raiseError("PEAR_Packager: mktemp failed");
         }
@@ -135,7 +141,7 @@
         $tar =& new Archive_Tar($dest_package, $compress);
         $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors
         // ----- Creates with the package.xml file
-        $ok = $tar->createModify($newpkgfile, '', $tmpdir);
+        $ok = $tar->createModify(array($newpkgfile), '', $tmpdir);
         if (PEAR::isError($ok)) {
             chdir($oldcwd);
             return $this->raiseError($ok);
Index: pear/PEAR/Registry.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Registry.php,v
retrieving revision 1.46
diff -u -r1.46 Registry.php
--- pear/PEAR/Registry.php	7 Jul 2003 15:42:58 -0000	1.46
+++ pear/PEAR/Registry.php	28 Jul 2003 22:50:12 -0000
@@ -146,7 +146,11 @@
     function _assertStateDir()
     {
         if (!@is_dir($this->statedir)) {
-            if (!System::mkdir("-p {$this->statedir}")) {
+            $opt = array(
+                        '-p',
+                        $this->statedir,
+                        );
+            if (!System::mkdir($opt)) {
                 return $this->raiseError("could not create directory '{$this->statedir}'");
             }
         }
Index: pear/PEAR/Remote.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Remote.php,v
retrieving revision 1.41
diff -u -r1.41 Remote.php
--- pear/PEAR/Remote.php	12 Jul 2003 14:25:06 -0000	1.41
+++ pear/PEAR/Remote.php	28 Jul 2003 22:50:12 -0000
@@ -56,7 +56,8 @@
         $id       = md5(serialize($args));
         $cachedir = $this->config->get('cache_dir');
         if (!file_exists($cachedir)) {
-            System::mkdir('-p '.$cachedir);
+            $opt = array('-p', $cachedir);
+            System::mkdir($opt);
         }
         $filename = $cachedir . DIRECTORY_SEPARATOR . 'xmlrpc_cache_' . $id;
         if (!file_exists($filename)) {
@@ -86,7 +87,8 @@
         $id       = md5(serialize($args));
         $cachedir = $this->config->get('cache_dir');
         if (!file_exists($cachedir)) {
-            System::mkdir('-p '.$cachedir);
+            $opt = array('-p', $cachedir);
+            System::mkdir($opt);
         }
         $filename = $cachedir.'/xmlrpc_cache_'.$id;
 


Reproduce code:
---------------
try any pear command/installation that involves writing to disk and creating temp files in C:\Program Files\PHP


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-30 04:01 UTC] arnaud@php.net
what is the status of this bug greg ?
 [2003-07-30 05:05 UTC] pajoye@php.net
Hello,

This is not a bug, as already said. This is more actually a documentation problem. On win32, you have to install PEAR using go-pear which does not allow spaces in pathnames.

I agree we shoud add a space detection in config-set.

Then this patch does not ""fix"" *only* the pathnames issues but also add the publicweb new things. This addition has to be discussed, and need a test phase to see if it fits really the goals.


Besides this nice addition, we will not add it in the next release which is in a RC phase.

That does not mean we do not appreciate this addition or we will not add it soon. That only means that does not fit the release QA process and is too risky to add one or the other now.

please refer to the archive about the how&why spaces in pathnames are not actually a bug (if you remember, I already explained the main reasons about this issue).

As a sidenote, it would be nice if you do not report the same things in many reports :).

pierre
 [2003-07-30 05:52 UTC] greg at chiaraquartet dot net
I give up.

go-pear.php does not have any requirement regarding spaces in pathnames.  The go-pear script uses the Installer, which as you notice in the patch, needs fixing along with the packager, common, config, registry and remote.  If you don't see the reason to fix PEAR on Windows after all the arguing I've done and after a simple patch that fixes it, then nothing will convince you, and that's that.

Greg

P.S. removing the 18 lines of the patch that implement publicweb is pretty tough too, so I did it for you.

Index: pear/PEAR/Common.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Common.php,v
retrieving revision 1.93
diff -u -r1.93 Common.php
--- pear/PEAR/Common.php	12 Jul 2003 15:15:38 -0000	1.93
+++ pear/PEAR/Common.php	29 Jul 2003 18:25:11 -0000
@@ -156,7 +156,12 @@
         $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
         while ($file = array_shift($tempfiles)) {
             if (@is_dir($file)) {
-                System::rm("-rf $file");
+                $options =
+                    array(
+                        '-rf',
+                        $file,
+                         );
+                System::rm($options);
             } elseif (file_exists($file)) {
                 unlink($file);
             }
@@ -198,7 +203,12 @@
     function mkDirHier($dir)
     {
         $this->log(2, "+ create dir $dir");
-        return System::mkDir("-p $dir");
+        $options =
+            array(
+                '-p',
+                $dir,
+                 );
+        return System::mkDir($options);
     }
 
     // }}}
@@ -242,11 +252,12 @@
     function mkTempDir($tmpdir = '')
     {
         if ($tmpdir) {
-            $topt = "-t $tmpdir ";
+            $topt = array('-t', $tmpdir);
         } else {
-            $topt = '';
+            $topt = array();
         }
-        if (!$tmpdir = System::mktemp($topt . '-d pear')) {
+        $topt = array_merge($topt, array('-d', 'pear'));
+        if (!$tmpdir = System::mktemp($topt)) {
             return false;
         }
         $this->addTempFile($tmpdir);
Index: pear/PEAR/Config.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Config.php,v
retrieving revision 1.48
diff -u -r1.48 Config.php
--- pear/PEAR/Config.php	3 Jul 2003 06:43:31 -0000	1.48
+++ pear/PEAR/Config.php	29 Jul 2003 18:25:11 -0000
@@ -577,7 +577,8 @@
         }
         $data = ($data === null) ? $this->configuration[$layer] : $data;
         $this->_encodeOutput($data);
-        if (!@System::mkDir("-p " . dirname($file))) {
+        $opt = array('-p', dirname($file));
+        if (!@System::mkDir($opt)) {
             return $this->raiseError("could not create directory: " . dirname($file));
         }
         if (@is_file($file) && !@is_writeable($file)) {
Index: pear/PEAR/Packager.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Packager.php,v
retrieving revision 1.48
diff -u -r1.48 Packager.php
--- pear/PEAR/Packager.php	27 Jun 2003 10:46:53 -0000	1.48
+++ pear/PEAR/Packager.php	29 Jul 2003 18:25:12 -0000
@@ -116,7 +116,13 @@
             chdir($oldcwd);
             return $this->raiseError($new_xml);
         }
-        if (!($tmpdir = System::mktemp('-t '.getcwd().' -d'))) {
+        $opt =
+            array(
+                '-t',
+                getcwd(),
+                '-d',
+                 );
+        if (!($tmpdir = System::mktemp($opt))) {
             chdir($oldcwd);
             return $this->raiseError("PEAR_Packager: mktemp failed");
         }
@@ -135,7 +141,7 @@
         $tar =& new Archive_Tar($dest_package, $compress);
         $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors
         // ----- Creates with the package.xml file
-        $ok = $tar->createModify($newpkgfile, '', $tmpdir);
+        $ok = $tar->createModify(array($newpkgfile), '', $tmpdir);
         if (PEAR::isError($ok)) {
             chdir($oldcwd);
             return $this->raiseError($ok);
Index: pear/PEAR/Registry.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Registry.php,v
retrieving revision 1.46
diff -u -r1.46 Registry.php
--- pear/PEAR/Registry.php	7 Jul 2003 15:42:58 -0000	1.46
+++ pear/PEAR/Registry.php	29 Jul 2003 18:25:13 -0000
@@ -146,7 +146,11 @@
     function _assertStateDir()
     {
         if (!@is_dir($this->statedir)) {
-            if (!System::mkdir("-p {$this->statedir}")) {
+            $opt = array(
+                        '-p',
+                        $this->statedir,
+                        );
+            if (!System::mkdir($opt)) {
                 return $this->raiseError("could not create directory '{$this->statedir}'");
             }
         }
Index: pear/PEAR/Remote.php
===================================================================
RCS file: /repository/php-src/pear/PEAR/Remote.php,v
retrieving revision 1.41
diff -u -r1.41 Remote.php
--- pear/PEAR/Remote.php	12 Jul 2003 14:25:06 -0000	1.41
+++ pear/PEAR/Remote.php	29 Jul 2003 18:25:13 -0000
@@ -56,7 +56,8 @@
         $id       = md5(serialize($args));
         $cachedir = $this->config->get('cache_dir');
         if (!file_exists($cachedir)) {
-            System::mkdir('-p '.$cachedir);
+            $opt = array('-p', $cachedir);
+            System::mkdir($opt);
         }
         $filename = $cachedir . DIRECTORY_SEPARATOR . 'xmlrpc_cache_' . $id;
         if (!file_exists($filename)) {
@@ -86,7 +87,8 @@
         $id       = md5(serialize($args));
         $cachedir = $this->config->get('cache_dir');
         if (!file_exists($cachedir)) {
-            System::mkdir('-p '.$cachedir);
+            $opt = array('-p', $cachedir);
+            System::mkdir($opt);
         }
         $filename = $cachedir.'/xmlrpc_cache_'.$id;
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Nov 29 18:03:14 2021 UTC