[PHP-BUG] Bug #64699 [NEW]: is_dir() is inaccurate result on Windows with japanese locale.
From: sharkpp at gmail dot com Operating system: Windows PHP version: 5.4.14 Package: Filesystem function related Bug Type: Bug Bug description:is_dir() is inaccurate result on Windows with japanese locale. Description: Environment I'm testing this problem on Windows 7 Ultimate x86 english. Configuration changes little is required to reproduce. 1. Please open "Control Panel". 2. Please click "Change display language" link. 3. Please select "Administrative" tab and click "Change system locale..." button. 4. Please change current system locale "Japanese(Japan)". The above procedure is not needed if you want to try in the Japanese versions of Windows. php in immediately after installation, the default state is also php.ini (does not exist). Problem is_dir() will lie If you create a folder that contains the "\x5C" in the string. It may is included in the second byte of Shift_JIS. For example ã½(\x83\x5C). More example: https://ja.wikipedia.org/wiki/Shift_JIS (japanese) Test script: --- @mkdir("a"); @mkdir("\x83\x5D"); @mkdir("\x83\x5C"); $dir = './'; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $path = $dir . $file; $type = filetype($path); $type2= is_dir($path) ? 'dir' : 'file'; $comp = $type == $type2 ? 'OK' : 'NG'; echo "filetype()[".str_pad($type, 4)."] == is_dir()[".str_pad($type2, 4)."] -> $comp: {$file}\n"; } closedir($dh); } Expected result: filetype()[dir ] == is_dir()[dir ] -> OK: . filetype()[dir ] == is_dir()[dir ] -> OK: .. filetype()[dir ] == is_dir()[dir ] -> OK: a filetype()[file] == is_dir()[file] -> OK: test.php filetype()[dir ] == is_dir()[file] -> NG: ã½ filetype()[dir ] == is_dir()[dir ] -> OK: ã¾ Actual result: -- filetype()[dir ] == is_dir()[dir ] -> OK: . filetype()[dir ] == is_dir()[dir ] -> OK: .. filetype()[dir ] == is_dir()[dir ] -> OK: a filetype()[file] == is_dir()[file] -> OK: test.php filetype()[dir ] == is_dir()[dir ] -> OK: ã½ filetype()[dir ] == is_dir()[dir ] -> OK: ã¾ -- Edit bug report at https://bugs.php.net/bug.php?id=64699&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64699&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64699&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64699&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64699&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64699&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64699&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64699&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64699&r=oldversion Not developer issue:https://bugs.php.net/fix.php?id=64699&r=support Expected behavior: https://bugs.php.net/fix.php?id=64699&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64699&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64699&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64699&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64699&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64699&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64699&r=isapi Install GNU Sed:https://bugs.php.net/fix.php?id=64699&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64699&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64699&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64699&r=mysqlcfg
Bug #64699 [Com]: is_dir() is inaccurate result on Windows with japanese locale.
Edit report at https://bugs.php.net/bug.php?id=64699&edit=1 ID: 64699 Comment by: sharkpp at gmail dot com Reported by:sharkpp at gmail dot com Summary:is_dir() is inaccurate result on Windows with japanese locale. Status: Open Type: Bug Package:Filesystem function related Operating System: Windows PHP Version:5.4.14 Block user comment: N Private report: N New Comment: Thank you. I hope a major version. Incidentally, php-wfio is not work. Because is_dir() is not implemented. Previous Comments: [2013-05-07 06:54:57] paj...@php.net For the record, it is not that it won't be fixed but can't be fixed at this stage but in a major version. Not only PHP's code and not only for file stream wrapper. [2013-05-07 06:36:39] ku at digitaldolphins dot jp Hi. It is known problem. And it won't be fixed. If you need a patch, check my one at: https://bugs.php.net/bug.php?id=61315 Or you can try php-wfio extension instead. https://code.google.com/p/php-wfio/ It needs to be built manually with step by step instruction. https://wiki.php.net/internals/windows/stepbystepbuild Try at your own risk! Thanks kenji uno. ---- [2013-04-23 15:48:54] sharkpp at gmail dot com Description: Environment I'm testing this problem on Windows 7 Ultimate x86 english. Configuration changes little is required to reproduce. 1. Please open "Control Panel". 2. Please click "Change display language" link. 3. Please select "Administrative" tab and click "Change system locale..." button. 4. Please change current system locale "Japanese(Japan)". The above procedure is not needed if you want to try in the Japanese versions of Windows. php in immediately after installation, the default state is also php.ini (does not exist). Problem is_dir() will lie If you create a folder that contains the "\x5C" in the string. It may is included in the second byte of Shift_JIS. For example ã½(\x83\x5C). More example: https://ja.wikipedia.org/wiki/Shift_JIS (japanese) Test script: --- @mkdir("a"); @mkdir("\x83\x5D"); @mkdir("\x83\x5C"); $dir = './'; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $path = $dir . $file; $type = filetype($path); $type2= is_dir($path) ? 'dir' : 'file'; $comp = $type == $type2 ? 'OK' : 'NG'; echo "filetype()[".str_pad($type, 4)."] == is_dir()[".str_pad($type2, 4)."] -> $comp: {$file}\n"; } closedir($dh); } Expected result: filetype()[dir ] == is_dir()[dir ] -> OK: . filetype()[dir ] == is_dir()[dir ] -> OK: .. filetype()[dir ] == is_dir()[dir ] -> OK: a filetype()[file] == is_dir()[file] -> OK: test.php filetype()[dir ] == is_dir()[file] -> NG: ã½ filetype()[dir ] == is_dir()[dir ] -> OK: ã¾ Actual result: -- filetype()[dir ] == is_dir()[dir ] -> OK: . filetype()[dir ] == is_dir()[dir ] -> OK: .. filetype()[dir ] == is_dir()[dir ] -> OK: a filetype()[file] == is_dir()[file] -> OK: test.php filetype()[dir ] == is_dir()[dir ] -> OK: ã½ filetype()[dir ] == is_dir()[dir ] -> OK: ã¾ -- Edit this bug report at https://bugs.php.net/bug.php?id=64699&edit=1