|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 22:00:02 2025 UTC |
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;