note 82770 added to function.realpath

From: Date: Thu, 24 Apr 2008 22:21:52 +0000
Subject: note 82770 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-138758@lists.php.net to get a copy of this message
Some users will notice that PHP applications malfunction when they upgrade to PHP 5.2.4 (included in Ubuntu 8.04 LTS) because realpath returns true for files that don't exist. This is due to the inclusion of the Hardened-PHP Project's Suhosin Patch in many distributions by default. This patch replaces PHPs realpath function with the BSD implementation, which ignores the last path component. The workaround is to use the file_exists function to verify that the file exists before using realpath to get its real path string. e.g: instead of: <?php if (realpath($path)) { $path = realpath($path); } else { throw new Exception('Path not found!'); } ?> Do this: <?php if (file_exists($path)) { $path = realpath($path); } else { throw new Exception('Path not found!'); } ?> See http://www.hardened-php.net/suhosin/a_feature_list:realpath.html ---- Server IP: 64.71.164.2 Probable Submitter: 71.42.115.245 ---- Manual Page -- http://www.php.net/manual/en/function.realpath.php Edit -- https://master.php.net/note/edit/82770 Del: integrated -- https://master.php.net/note/delete/82770/integrated Del: useless -- https://master.php.net/note/delete/82770/useless Del: bad code -- https://master.php.net/note/delete/82770/bad+code Del: spam -- https://master.php.net/note/delete/82770/spam Del: non-english -- https://master.php.net/note/delete/82770/non-english Del: in docs -- https://master.php.net/note/delete/82770/in+docs Del: other reasons-- https://master.php.net/note/delete/82770 Reject -- https://master.php.net/note/reject/82770 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138758) next »