Req #75000 [NEW]: getcwd() does not raise error when it fails

From: Date: Fri, 28 Jul 2017 06:09:06 +0000
Subject: Req #75000 [NEW]: getcwd() does not raise error when it fails
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210381@lists.php.net to get a copy of this message
From: marco dot agnoli at me dot com Operating system: OS X PHP version: 7.1.7 Package: *General Issues Bug Type: Feature/Change Request Bug description:getcwd() does not raise error when it fails Description: ------------ Some functions like chdir() raise an error when they fail, but others like getcwd() don't. I don't see why getcwd() should not raise an error. This makes catching errors more painful than it should be. Test script: --------------- <?php var_dump(getcwd()); // Remove traversal permission for the current directory system('chmod -x '.escapeshellarg(__DIR__)); /** * I would expect an error here * because getcwd() returns false here. */ var_dump(getcwd()); // Restore traversal permission system('chmod +x '.escapeshellarg(__DIR__)); ?> Expected result: ---------------- A warning from PHP that getcwd() failed. Actual result: -------------- getcwd() silently returns false. -- Edit bug report at https://bugs.php.net/bug.php?id=75000&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75000&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75000&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75000&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75000&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75000&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75000&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75000&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75000&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75000&r=support Expected behavior: https://bugs.php.net/fix.php?id=75000&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75000&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75000&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75000&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75000&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75000&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75000&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75000&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75000&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75000&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75000&r=mysqlcfg

« previous php.bugs (#210381) next »