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

Bug #16976 The phpcs attempts to process symbolic links that don't resolve to files
Submitted: 2010-01-07 03:10 UTC
From: mdwyer Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.2.1)
PHP Version: Irrelevant OS: Mac OS X 10.6.2
Roadmaps: (Not assigned)    
Subscription  


 [2010-01-07 03:10 UTC] mdwyer (Michael Dwyer)
Description: ------------ If you have a directory with the file test.php in it, then open and modify it with Emacs, it will create a symbolic link .#test.php in the same directory that points to a non-existant file (the name of which is used in Emacs's file locking scheme) The function realPath() when applied to this (or any other symbolic link that does not resolve to a real file) returns null. CodeSniffer- >processFiles() was not checking for this condition and proceeded to try to run CodeSniffer->processFile() on a file that did not exist, triggering an exception. On two separate Mac OS X machines the utility would stop completely at this point. On an Ubuntu server, however, it would keep going. I have attached a small patch.

Comments

 [2010-01-07 03:17 UTC] mdwyer (Michael Dwyer)
 [2010-01-11 03:08 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
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. The realPath() function actually returns FALSE if the file does not exist, and also appears to return FALSE if the link is invalid. So I've just put a check in to see if the return value is FALSE. If so, the file is skipped. Grab the latest code from SVN, or patch CodeSniffer.php with: if ($filePath === false) continue; And see if it works for you. It's working on OS X for me.