Bug #79486 [NEW]: file_exists() returns true for a non-existant file

From: Date: Fri, 17 Apr 2020 12:14:12 +0000
Subject: Bug #79486 [NEW]: file_exists() returns true for a non-existant file
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226635@lists.php.net to get a copy of this message
From:             m dot staab at complex-it dot de
Operating system: windows10 x64
PHP version:      7.4.5
Package:          *General Issues
Bug Type:         Bug
Bug description:file_exists() returns true for a non-existant file

Description:
------------
I am running into a mysterious problem, where php's file_exists()
returns TRUE for a path, where no file exists.

I tried opening the filepath via notepad++ or the windows explorer, and
every tool is telling me that the path points to a non-existant file...
except php..

putting the offending path into a plain 3 lines php file it reports
false though.

since its really hard to reproduce (even when copying the paths 1:1) it
might be a deeper php issue, e.g. opcache statcache or similar.

I tried invoking clearstatcache() before the file_exists() but this does
not change the output

Test script:
---------------
error not reproducible with

```
<?php

var_dump(file_exists('C:\Users\mstaab\Documents\GitHub\kunzmann\app\shop\models\clxBaureihe.php'));
```

but at runtime when my sources look like things look different


        foreach (array(
            self::$model_paths,
            self::$lib_paths,
            self::$helper_paths,
            self::$controller_paths,
            self::$plugin_paths
        ) as $paths) {
            foreach ($paths as $path => $dummyVal) {
                if (file_exists($path . DIRECTORY_SEPARATOR . $file)) {
                    if ($class_name == 'clxBaureihe') {
                        var_dump($class_name); // "clxBaureihe"
                        var_dump($path); //
"C:\Users\mstaab\Documents\GitHub\kunzmann/app/shop/models"

                        var_dump($file); // "clxBaureihe.php"
                        var_dump($path . DIRECTORY_SEPARATOR . $file);
//
"C:\Users\mstaab\Documents\GitHub\kunzmann/app/shop/models\clxBaureihe.php"
                        var_dump(file_exists($path . DIRECTORY_SEPARATOR
. $file)); // bool(true)
                    }


Expected result:
----------------
file_exists() should return false on non-existing files

Actual result:
--------------
it returns true

-- 
Edit bug report at https://bugs.php.net/bug.php?id=79486&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79486&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79486&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79486&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79486&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79486&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79486&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79486&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79486&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79486&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79486&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79486&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79486&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79486&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79486&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79486&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79486&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79486&r=mysqlcfg


Thread (17 messages)

« previous php.bugs (#226635) next »