#37918 [NEW]: file_exists() failes on long filenames (gt 259)
From: mrueegg at metaworx dot ch
Operating system: Windows NT 5.1 build 2600 (WiXP)
PHP version: 5CVS-2006-06-26 (snap)
PHP Bug Type: Filesystem function related
Bug description: file_exists() failes on long filenames (gt 259)
Description:
------------
on my windows system the function file_exists() returns true whenever the
full qualified file path has more than a total of 259 characters.
if the path is relative, the cwd will be prepended and counted (e.g.
260-28=232).
i testet it with the snapshot of today (26-Jun-2006 16:19) as well. plain
php.exe, no changes to modules or php.ini. same result.
i use an immaginary filename in the root of 'C:\'. the file obviously does
not exist.
refer to http://bugs.php.net/bug.php?id=31347
describing the similar error
with strlen > 255.
Reproduce code:
---------------
<?php
echo php_uname();
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
echo "Running on Windows with PHP ", phpversion(), "\n";
$root = "c:".DIRECTORY_SEPARATOR;
} else {
die("problem could not be reproduced on linux (debian with PHP
5.1.2-1+b1)\n");
}
$max = 260;
$t = $root.str_repeat('x', $max - strlen($root));
var_dump(strlen($t));
var_dump(file_exists($t));
$t = $root.str_repeat('x', $max - strlen($root) - 1);
var_dump(strlen($t));
var_dump(file_exists($t));
echo "\nif no root is given, then cwd is prepended:\n";
var_dump(getcwd().DIRECTORY_SEPARATOR);
var_dump(strlen(getcwd().DIRECTORY_SEPARATOR));
echo "\n";
$t = str_repeat('x', $max - strlen(getcwd().DIRECTORY_SEPARATOR));
var_dump(strlen($t));
var_dump(file_exists($t));
$t = str_repeat('x', $max - strlen(getcwd().DIRECTORY_SEPARATOR) - 1);
var_dump(strlen($t));
var_dump(file_exists($t));
Expected result:
----------------
Windows NT MWXDEV 5.1 build 2600
Running on Windows with PHP 5.1.4
int(260)
bool(false)
int(259)
bool(false)
if no root is given, then cwd is prepended:
string(28) "P:\Programming\xampp\htdocs\"
int(28)
int(232)
bool(false)
int(231)
bool(false)
an exception/warning would also be acceptable. but in case of doubt the
function should return false.
Actual result:
--------------
Windows NT MWXDEV 5.1 build 2600
Running on Windows with PHP 5.1.4
int(260)
bool(true)
int(259)
bool(false)
if no root is given, then cwd is prepended:
string(28) "P:\Programming\xampp\htdocs\"
int(28)
int(232)
bool(true)
int(231)
bool(false)
--
Edit bug report at http://bugs.php.net/?id=37918&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37918&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37918&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37918&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37918&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37918&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37918&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37918&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37918&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37918&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37918&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37918&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37918&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37918&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37918&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37918&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37918&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37918&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37918&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37918&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37918&r=mysqlcfg
Thread (4 messages)
- mrueegg at metaworx dot ch