Bug #70139 [Asn->Csd]: is_link or DirectoryIterator->isLink don't work
| From: | tomkrawc at gmail dot com | Date: | Thu, 30 Jul 2015 14:29:47 +0000 |
| Subject: | Bug #70139 [Asn->Csd]: is_link or DirectoryIterator->isLink don't work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194836@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70139&edit=1
ID: 70139
User updated by: tomkrawc at gmail dot com
Reported by: tomkrawc at gmail dot com
Summary: is_link or DirectoryIterator->isLink don't work
-Status: Assigned
+Status: Closed
Type: Bug
Package: Filesystem function related
Operating System: Windows 7 64bit
PHP Version: 5.5.27
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
It locks it was problem with incorectly used clearstatcache() function.
Previous Comments:
------------------------------------------------------------------------
[2015-07-29 05:16:57] tomkrawc at gmail dot com
I don't know what to say. Yesterday the script http://pastebin.com/6h1G6ku5 was creating such an output http://pastebin.com/Z4c4pUDs. Today it returns expected
results.
The code of @requinix results that way http://pastebin.com/3PxHQU30. So it is correct.
I don't know why it works today...
------------------------------------------------------------------------
[2015-07-29 00:08:16] requinix@php.net
Wrote this and my Win 8.1 with PHPs 5.4.29, 5.5.13, 5.6.11 don't reproduce: is_file says no,
is_dir and is_link say yes.
Note that you will probably need an elevated command prompt to run mklink.
<?php
$tempnam = tempnam(sys_get_temp_dir(), "php");
unlink($tempnam); // tempnam created a file
// expecting to see "symbolic link created for %s <<===>> C:\"
// - /d to create a directory symlink
// - /j to create a junction
passthru("mklink /d " . escapeshellarg($tempnam) . " C:\\");
clearstatcache();
if (file_exists($tempnam)) {
echo "Created directory {$tempnam}\n";
echo "- is_file: ", (is_file($tempnam) ? "yes" : "no"),
"\n";
echo "- is_dir: ", (is_dir($tempnam) ? "yes" : "no"),
"\n";
echo "- is_link: ", (is_link($tempnam) ? "yes" : "no"),
"\n";
rmdir($tempnam) or printf("Failed to remove directory\n");
} else {
echo "Directory {$tempnam} does not exist\n";
}
?>
------------------------------------------------------------------------
[2015-07-28 23:39:04] cmb@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
See also <http://sscce.org/>.
------------------------------------------------------------------------
[2015-07-26 10:12:26] tomkrawc at gmail dot com
Description:
------------
Neighter is_link nor DirectoryIterator->isLink are not distinguish symlinks created with os
command mklink. Os is showing them:
2015-07-26 09:23 <DIR> .
2015-07-26 09:23 <DIR> ..
2015-05-23 20:55 <DIR> _backup
2015-05-23 20:55 <DIR> _logi
2015-07-26 09:23 <DIR> fileadmin
2015-07-26 08:39 <SYMLINKD> typo3 [typo3_src\typo3]
2015-07-26 08:39 <SYMLINKD> typo3_src [..\typo3_src-6.2.14]
2015-07-26 09:23 <DIR> typo3conf
2015-07-26 09:23 <DIR> typo3temp
2015-07-26 09:23 <DIR> uploads
2015-05-24 10:12 5Â 199 .htaccess
2015-04-14 20:03 113 index.html
2015-07-26 08:39 <SYMLINK> index.php [typo3_src\index.php]
2015-05-23 18:40 19 pi.php
My env is Win 7 x64, WAMP (Apache 2.4.9, PHP 5.5.12 Thread Safe).
Test script:
---------------
if ($handle = opendir($dir)) {
echo "Directory handle: $handle\n";
echo "Entries:\n";
while (false !== ($entry = readdir($handle))) {
if (is_link($dir . $entry)) {
$strTarget = readlink($entry);
echo '>>LINK<<: ' . $entry . ' => ' . $strTarget .
"\n";
}
elseif (is_file($dir . $entry)) {
echo 'File: ' . $entry . "\n";
}
elseif (is_dir($dir . $entry)) {
echo 'Dir: ' . $entry . "\n";
}
else {
echo "? - $entry\n";
}
}
closedir($handle);
}
Expected result:
----------------
both of those methods should return true
Actual result:
--------------
both of those methods should return false
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70139&edit=1