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

Bug #12023 substr() miss around $package_directory in getFileList()
Submitted: 2007-09-11 13:11 UTC
From: msakamoto Assigned: farell
Status: Closed Package: PEAR_PackageFileManager (version 1.6.1)
PHP Version: 5.2.4 OS: WindowsXP
Roadmaps: (Not assigned)    
Subscription  


 [2007-09-11 13:11 UTC] msakamoto (Masahiko Sakamoto)
Description: ------------ In PEAR_PackageFileManager_File#getFileList(), if 'packagedirectory' terminates with '/'(directory separator), result of file 'path' will be wrong. File : /your/package/directory/foo/bar.php 'packagedirectory' : /your/package/directory/ (it'll equal dirname(__FILE__) in many cases.) This will be: /your/package/directory/oo/bar.php I solve this problem. I switch the character index (= cut point of substr()) according to whether 'packagedirectory' terminate with '/' or not. See details my patch which was posted with this report.

Comments

 [2007-09-11 13:17 UTC] msakamoto (Masahiko Sakamoto)
I'm msakamoto. Sorry, I missed patch file attachement. See B12023_p01 patch.
 [2007-09-11 13:20 UTC] msakamoto (Masahiko Sakamoto)
Oh, no... sorry. My patch isn't "cvs diff -u". My patch is about local files from PEAR stable release. (PEAR/PackageFileManager/File.php)
 [2007-10-09 10:02 UTC] timj (Tim Jackson)
Whilst I see what you're saying, I can't immediately reproduce the problem on Linux - adding a trailing / to packagedirectory doesn't seem to cause any harm. I wonder if it's a Windows-specific thing somehow?
 [2007-10-11 06:53 UTC] msakamoto (Masahiko Sakamoto)
timj, thank you for your comment. Yes, I tried latest version(PEAR_PackageFileManager-1.6.2) on my linux box (PHP4.4.7), but I couldn't reproduce this problem, too. By more trial, I found that the reason is difference of realpath() behaviour between PHP4 and PHP5 when realpath() called with trailing DIRECTORY_SEPARATOR(DS) on Windows. (I tried PHP4.4.7 and PHP5.2.4 on WinXP SP2) Imagine there's "C:\temp" direcotry. If you calls realpath() without trailing DS: > php -r "echo realpath('c:\\temp');" This will result "C:\\temp" on both PHP4 and PHP5. But if you calls realpath() with trailing DS: > php -r "echo realpath('c:\\temp\\');" on PHP4: "c:\\temp" BUT on PHP5: "c:\\temp\\" !!!!!! I couldn't believe this result ... BUT, it is the FACT.
 [2007-10-28 18:58 UTC] quipo (Lorenzo Alberton)
I can confirm the reported behavior on Windows. A simpler patch is attached.
 [2007-10-29 02:13 UTC] msakamoto (Masahiko Sakamoto)
quipo (Lorenzo Alberton), Thank you for your reproduction confirmation and simpler patch. I confirmed that your patch works correctly on PHP4(WinXPSP2, Linux box) and PHP5(WinXPSP2). Thank you!
 [2007-10-29 21:37 UTC] dufuz (Helgi Þormar Þorbjörnsson)
I can confirm this bug on windows vista
 [2007-11-09 07:18 UTC] lsolesen (Lars Olesen)
I can confirm it on windows, and would like to know when a new release might be released? Here is a testcase which will show the problem. Use both the directories and the bug_cutsoffirstletterofrootdirectories.phpt. http://svn.intraface.dk/intrafacepublic/3Party/PEAR/PEAR_PackageFileManager2/tests/
 [2007-11-14 10:31 UTC] dufuz (Helgi Þormar Þorbjörnsson)
Like Laurent pointed out in PEAR dev,this only affects PHP 5.2.4 it seems on Windows, http://bugs.php.net/bug.php?id=43248 but the patch Lorenzo pro vided is still valid
 [2007-11-20 08:49 UTC] farell (Laurent Laville)
This bug has been fixed in CVS. 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.