Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.4

Bug #16406 addReplacement does not look for files in packagedirectory
Submitted: 2009-07-05 23:58 UTC
From: sunejensen Assigned: dufuz
Status: Closed Package: PEAR_PackageFileManager2 (version 1.0.0)
PHP Version: 5.2.5 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2009-07-05 23:58 UTC] sunejensen (Sune Jensen)
Description: ------------ The method PackageFileManager2->addReplacement() uses glob() to find files to add replacement to. But glob does not look in the folder set by the packagedirectory option. This means no replacements is added. I have attached a fix to the problem.

Comments

 [2009-07-06 00:00 UTC] sunejensen (Sune Jensen)
The following patch has been added/updated: Patch Name: look-in-packagedirectory Revision: 1246820424 URL: http://pear.php.net/bugs/patch-display.php?bug=16406&patch=look-in-packagedirectory&revision=1246820424&display=1
 [2009-07-06 14:05 UTC] doconnor (Daniel O'Connor)
Would it be possible for you to add a small test case, so that we can better judge the problem your patch fixes?
 [2009-07-16 05:32 UTC] doconnor (Daniel O'Connor)
The patch you've provided changed the current working directory and never restores it. Can you correct that, and also add test coverage?
 [2009-07-16 13:15 UTC] sunejensen (Sune Jensen)
Testing addReplacement when packagedirectory is set Create this file structure: ./testAddReplacementWorksWithWorkingDir.php ./src/Class.php (empty file) -- test script: testAddReplacementWorksWithWorkingDir.php -- <?php require_once 'PEAR/PackageFileManager2.php'; $pfm = new PEAR_PackageFileManager2(); $pfm->setOptions( array( 'baseinstalldir' => '/', 'filelistgenerator' => 'file', 'packagedirectory' => 'src', 'packagefile' => 'package.xml' ) ); $pfm->setPackage('Test'); $pfm->setSummary('Test'); $pfm->setDescription('Test'); $pfm->setUri('__uri'); $pfm->setLicense('LGPL License', 'http://www.gnu.org/licenses/lgpl.html'); $pfm->addMaintainer('lead', 'sunetjensen', 'Sune Jensen', 'sune@intraface.dk'); $pfm->setPackageType('php'); $pfm->setAPIVersion('0.0.1'); $pfm->setReleaseVersion('0.0.1'); $pfm->setAPIStability('alpha'); $pfm->setReleaseStability('alpha'); $pfm->setNotes('release'); $pfm->addRelease(); $pfm->clearDeps(); $pfm->setPhpDep('5.2.0'); $pfm->setPearinstallerDep('1.8.1'); // Add replacement relative to package directory $pfm->addReplacement('Class.php', 'pear-config', '@php-dir@', 'php_dir'); $pfm->generateContents(); $pfm->writePackageFile(); $res = $pfm->debugPackageFile(); if(PEAR::isError($res)) { echo $res->toString()."\n"; } -- expected result -- [ZIP] <contents> <dir baseinstalldir="/" name="/"> <file baseinstalldir="/" md5sum="d41d8cd98f00b204e9800998ecf8427e" name="Class.php" role="php"> <tasks:replace from="@php-dir@" to="php_dir" type="pear-config" /> </file> </dir> </contents> [ZIP] -- actual result -- [ZIP] <contents> <dir baseinstalldir="/" name="/"> <file baseinstalldir="/" md5sum="d41d8cd98f00b204e9800998ecf8427e" name="Class.php" role="php"> </file> </dir> </contents> [ZIP]
 [2009-07-16 13:18 UTC] sunejensen (Sune Jensen)
The working directory is restored in the attached patch with the use of line 1 and 4: 1: $current_dir = getcwd(); 2: chdir($this->_options['packagedirectory']); 3: $glob = defined('GLOB_BRACE') ? glob($path, GLOB_BRACE) : glob($path); 4: chdir($current_dir);
 [2009-10-10 17:09 UTC] sunejensen (Sune Jensen)
Are you going to implement this patch?
 [2010-02-04 04:23 UTC] cweiske (Christian Weiske)
-Status: Open +Status: Verified
 [2010-10-29 22:01 UTC] tonybibbs (Tony Bibbs)
Same exact problem MacOSX 10.6 PHP 5.3.2 and PEAR 1.9.1. The patch (supplied over 15 months ago) works.
 [2011-03-24 04:05 UTC] dufuz (Helgi Þormar Þorbjörnsson)
-Status: Verified +Status: Closed -Assigned To: +Assigned To: dufuz
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.