Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FileSystem doesn't handle "broken" file_exists() #16783

Closed
@flip111

Description

@flip111

I'm unable to clear my cache with console cache:clear because file_exists() returns a wrong value (false). So FileSystem can not execute rmdir later on because the directory is not empty (because symfony didn't delete the file because it thought it was not there)

if (!file_exists($file) && !is_link($file)) {

This happens when the path+filename is 259 characters or longer. See also: http://superuser.com/a/467814

below you can see a test script demonstrating this problem

<?php
$foo = 'D:\\dev\\http\\tproj\\app\\cache\\dev_old\\annotations\\72\\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b.doctrinecache.data';
$bar = 'D:\\dev\\http\\tproj\\app\\cache\\dev_old\\annotations\\72\\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b315d.doctrinecache.data';
$foo_obj = new \SplFileInfo($foo);
$bar_obj = new \SplFileInfo($bar);
var_dump($foo, file_exists($foo), file_exists($foo_obj));
var_dump($bar, file_exists($bar), file_exists($bar_obj));

console:

D:\dev\http\tproj>php del.php
string(258) "D:\dev\http\tproj\app\cache\dev_old\annotations\72\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e43
6f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b.doctrinecache.data"
bool(true)
bool(true)
string(262) "D:\dev\http\tproj\app\cache\dev_old\annotations\72\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e43
6f6e74726f6c6c657223676574416e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b315d.doctrinecache.data"
bool(false)
bool(false)

D:\dev\http\tproj>dir D:\dev\http\tproj\app\cache\dev_old\annotations\72\
 Volume in drive D is Data
 Volume Serial Number is 2E83-BAB4

 Directory of D:\dev\http\tproj\app\cache\dev_old\annotations\72

01-12-2015  15:09    <DIR>          .
01-12-2015  15:09    <DIR>          ..
01-12-2015  15:04                 9 5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c65722367657441
6e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b.doctrinecache.data
01-12-2015  15:01                 9 5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726f6c6c65725c457863657074696f6e436f6e74726f6c6c65722367657441
6e64436c65616e4f7574707574427566666572696e67405b416e6e6f745d5d5b315d.doctrinecache.data
               2 File(s)             18 bytes
               2 Dir(s)   7.241.150.464 bytes free

I get this problem while upgrading from symfony 2.7 to symfony 2.8
My platform is windows 7 64 bits running PHP 5.6.10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions