|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-01-25 23:24 UTC] nospam at unclassified dot de
Description:
------------
This is what I do:
glob("pages/[Cc][Oo][Nn][Tt][Aa][Cc][Tt]/[Oo][Dd][Ll][Rr]0[Vv][Ss]8[Cc][Gg][Rr][Jj][Bb][Ii][Ll][Aa][Ww][Gg][Pp][Nn][Bb][Tt][Rr]4[Uu][Dd]3[Bb][Nn][Kk][Aa][Ee]/[Dd][Ee][Mm][Oo]/[Ii][Mm][Gg]/[Vv][Ss]2018[Jj][Aa][Vv][Aa][Ss][Cc][Rr][Ii][Pp][Tt][Ww][Aa][Rr][Nn][Ii][Nn][Gg][Ss].[Pp][Nn][Gg]")
This is what I get:
Warning: glob(): Pattern exceeds the maximum allowed length of 260 characters
The string passed to glob() is 279 characters long. And it may even be longer. I has to be this complicated to determine the correct casing of a file name on disk.
This restriction is neither documented nor understandable. The pattern length should not matter at all. And even if you think that file paths of actual files in the filesystem are limited to 260 characters on Windows, you may need to update your knowledge from at least 20 years ago. This restriction only exists for deprecated legacy software, which I hope PHP is not.
Test script:
---------------
See above.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 19:00:01 2025 UTC |
If you're on Windows then case doesn't matter, and even if it did this feels like an abuse of glob(). Tokenizing by slash and recursively scandir()ing makes more sense to me. It's true that PHP's glob() limits the pattern to MAXPATHLEN characters when this doesn't quite make sense - with features like [] and {} the pattern can certainly be longer than the filenames it would match. So perhaps that check should be dropped. Regardless, on my Win 10 PHP 7.1 the (PHP_)MAXPATHLEN is 2048 and your code runs fine. What SAPI (eg, php-fpm, cli) are you running this from, and did you get PHP from windows.php.net or somewhere else?