Hi, This bug:
http://bugs.php.net/bug.php?id=46680 uncovers 2 larger issues. 1) Where should a function like file_put_contents() create its file if it doesn't already exist and FILE_USE_INCLUDE_PATH is specified? The test for this is ext/standard/file/file_put_contents_variation4.phpt and a few others. file_put_contents($filename, "File in include path", FILE_USE_INCLUDE_PATH); arbitrarily creates $filename in the first portion of include_path on PHP 5.2, and arbitrarily creates $filename in cwd in PHP 5.3. Of course, if the file already exists in any of the include_path, both PHP 5.2 and 5.3 will overwrite it. The same is true of fopen() in write mode. 2) Should file_get_contents()/fopen() in read mode fall back to current directory if not found in include_path? The test for this is ext/standard/file/fopen_variation5.phpt and others In PHP 5.2, the functions simply fail if the file does not exist in include_path. Thus if include_path does not contain ".", the file is not found. In PHP 5.3, there is a fallback to check cwd for the file. For #1 I think both PHP 5.2 and 5.3 are broken. If you specify that a file should be written to inside include_path, it should fail if no file is found - allowing arbitrary file creation is just plain stupid and also dangerous - include_path has no business being used to create a file, it should only be used to find existing files. In any case, I think allowing include_path to be used at all for file modification is horrendous, and think it should be deprecated and removed from PHP 6. We should simply add file_resolve_path() function which can be used to locate a file. <?php if ($path = file_resolve_path('somefile.txt')) { file_put_contents($path, 'blah'); } else { file_put_contents($someOtherPath, 'blah'); } ?> For #2 I think PHP 5.3 is broken, and the fallback to cwd should be removed from php_resolve_path. Comments? Greg P.S. the tests themselves should not create directories outside of their tests/ subdirectory, and should use things like PATH_SEPARATOR, but that's a minor issue -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php