|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-04-17 12:14 UTC] m dot staab at complex-it dot de
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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 01:00:01 2025 UTC |
a few more tests var_dump(is_readable($path . DIRECTORY_SEPARATOR . $file)); // true var_dump(stat($path . DIRECTORY_SEPARATOR . $file)); array(26) { [0]=> int(2056) [1]=> int(19679399) [2]=> int(33204) [3]=> int(1) [4]=> int(1000) [5]=> int(1000) [6]=> int(0) [7]=> int(1) [8]=> int(1587125995) [9]=> int(1587125995) [10]=> int(1587125995) [11]=> int(-1) [12]=> int(-1) ["dev"]=> int(2056) ["ino"]=> int(19679399) ["mode"]=> int(33204) ["nlink"]=> int(1) ["uid"]=> int(1000) ["gid"]=> int(1000) ["rdev"]=> int(0) ["size"]=> int(1) ["atime"]=> int(1587125995) ["mtime"]=> int(1587125995) ["ctime"]=> int(1587125995) ["blksize"]=> int(-1) ["blocks"]=> int(-1) }I reproduce the error on ubuntu18 with php 7.2 with the following commands: $ GITHUB_ACTION=1 php vendor/bin/php-cs-fixer fix -vvv string(75) "clxKunzmann=>/cluster/www/www/www/kunzmann/app/shared/lib/clxKunzmann.php 1" string(105) "CmsContext=>/cluster/www/www/www/kunzmann/vendor/plugins/rocket/builtin/models/modulecms/CmsContext.php 1" string(93) "cms\ViewTypeProvider=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/ViewTypeProvider.php 1" string(77) "cms\ViewType=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/ViewType.php 1" string(83) "cms\UrlProvider=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/UrlProvider.php 1" string(113) "CmsUrlProvider=>/cluster/www/www/www/kunzmann/vendor/plugins/rocket/builtin/models/modulecms/CmsUrlProvider.php 1" string(119) "CmsModuleMetaData=>/cluster/www/www/www/kunzmann/vendor/plugins/rocket/builtin/models/modulecms/CmsModuleMetaData.php 1" string(95) "cms\metadata\shop\Usp=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/shop/Usp.php 1" string(109) "cms\metadata\ModuleMetaTrait=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/ModuleMetaTrait.php 1" string(128) "CmsInputTypeText=>/cluster/www/www/www/kunzmann/vendor/plugins/rocket/builtin/models/modulecms/inputtypes/CmsInputTypeText.php 1" string(109) "CmsInputType=>/cluster/www/www/www/kunzmann/vendor/plugins/rocket/builtin/models/modulecms/CmsInputType.php 1" string(99) "cms\metadata\Navigation=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Navigation.php 1" string(85) "cms\metadata\Gap=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Gap.php 1" string(97) "cms\metadata\Accordion=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Accordion.php 1" string(105) "cms\metadata\Contactperson=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Contactperson.php 1" string(95) "cms\metadata\Carousel=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Carousel.php 1" string(111) "cms\metadata\ImageMultiColumn=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/ImageMultiColumn.php 1" string(101) "cms\metadata\Vehiclelist=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Vehiclelist.php 1" string(115) "cms\metadata\VehicleQuickSearch=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/VehicleQuickSearch.php 1" string(101) "cms\metadata\Contactform=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Contactform.php 1" string(89) "cms\metadata\Brand=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Brand.php 1" string(93) "cms\metadata\Masonry=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Masonry.php 1" string(105) "cms\metadata\Testdriveform=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Testdriveform.php 1" string(101) "cms\metadata\Productlist=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Productlist.php 1" string(105) "cms\metadata\Productrating=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Productrating.php 1" string(105) "cms\metadata\Productslider=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Productslider.php 1" string(91) "cms\metadata\Slider=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Slider.php 1" string(95) "cms\metadata\Location=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Location.php 1" string(87) "cms\metadata\Text=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Text.php 1" string(103) "cms\metadata\TextAndImage=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/TextAndImage.php 1" string(109) "cms\metadata\TextMultiColumn=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/TextMultiColumn.php 1" string(93) "cms\metadata\Divider=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Divider.php 1" string(93) "cms\metadata\Heading=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Heading.php 1" string(89) "cms\metadata\Video=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Video.php 1" string(95) "cms\metadata\Benefits=>/cluster/www/www/www/kunzmann/app/shared/lib/cms/metadata/Benefits.php 1" string(79) "ClxShopPortal=>/cluster/www/www/www/kunzmann/app/shared/lib/ClxShopPortal.php 1" Loaded config default from "/cluster/www/www/www/kunzmann/.php_cs.dist". Using cache file ".php_cs.cache". string(92) "KMAccountController=>/cluster/www/www/www/kunzmann/app/shop/models/KMAccountController.php 1" Fatal error: require_once(): Failed opening required '/cluster/www/www/www/kunzmann/app/shop/models/KMAccountController.php' (include_path='.:/usr/share/php') in /cluster/www/www/www/kunzma nn/vendor/plugins/rocket/lib/Rocket.php on line 313 string(82) "CacheMemcached=>/cluster/www/www/www/kunzmann/app/shop/models/CacheMemcached.php 1" Fatal error: require_once(): Failed opening required '/cluster/www/www/www/kunzmann/app/shop/models/CacheMemcached.php' (include_path='.:/usr/share/php') in /cluster/www/www/www/kunzmann/ve ndor/plugins/rocket/lib/Rocket.php on line 313 the php code(parts) which trigger the output and the error is // snip /* * The include mechanism over all paths */ foreach ([ 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)) { self::$classMap[$class_name] = $path.DIRECTORY_SEPARATOR.$file; break 2; } } } // trigger cache re-newal, but only once per request if (!self::$shutdownRegistered) { self::$shutdownRegistered = true; register_shutdown_function([ __CLASS__, 'storeCache', ]); } // require the already validated path if (isset(self::$classMap[$class_name])) { clearstatcache(true); var_dump($class_name . '=>'. self::$classMap[$class_name] . ' '. file_exists(self::$classMap[$class_name])); require_once self::$classMap[$class_name]; return true; } // Remember that this class does not exist. self::$missingClassMap[$class_name] = true; // snip the strace of the command `GITHUB_ACTION=1 sudo strace php vendor/bin/php-cs-fixer fix -vvv 2> strace.out` can be found here: https://gist.github.com/clxmstaab/3773f5e76cd1b266b2b7b952ddd177d6for whatever reason, I have the feeling php is mixing up /cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php with /cluster/www/www/www/kunzmann/app/shop/controllers/KMAccountController.php /cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php is a totally valid path and the file exists.if relevant: here is the result of the "stat" command when executed via php on ubuntu18lts php -v PHP 7.2.30-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Apr 19 2020 07:50:50) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.30-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies $ tail /www/www/logs/php_errors.log [24-Apr-2020 11:37:07 Europe/Berlin] PHP Fatal error: require(): Failed opening required '/cluster/www/www/www/kunzmann/app/admin/models/Filter.php' (include_path='.:/usr/share/php') in /c luster/www/www/www/kunzmann/vendor/symfony/class-loader/MapClassLoader.php on line 53 [24-Apr-2020 11:37:11 Europe/Berlin] PHP Fatal error: require(): Failed opening required '/cluster/www/www/www/kunzmann/app/admin/models/Filter.php' (include_path='.:/usr/share/php') in /c luster/www/www/www/kunzmann/vendor/symfony/class-loader/MapClassLoader.php on line 53 [24-Apr-2020 11:38:09 Europe/Berlin] PHP Fatal error: require(): Failed opening required '/cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php' (include_path='.:/us r/share/php') in /cluster/www/www/www/kunzmann/vendor/symfony/class-loader/MapClassLoader.php on line 53 [24-Apr-2020 11:38:24 Europe/Berlin] PHP Fatal error: require(): Failed opening required '/cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php' (include_path='.:/us r/share/php') in /cluster/www/www/www/kunzmann/vendor/symfony/class-loader/MapClassLoader.php on line 53 [24-Apr-2020 11:39:44 Europe/Berlin] PHP Fatal error: require(): Failed opening required '/cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php' (include_path='.:/us r/share/php') in /cluster/www/www/www/kunzmann/vendor/symfony/class-loader/MapClassLoader.php on line 53 [24-Apr-2020 11:40:09 Europe/Berlin] PHP Fatal error: require(): Failed opening required '/cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php' (include_path='.:/us r/share/php') in /cluster/www/www/www/kunzmann/vendor/symfony/class-loader/MapClassLoader.php on line 53 [24-Apr-2020 11:40:21 Europe/Berlin] PHP Fatal error: require(): Failed opening required '/cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php' (include_path='.:/us r/share/php') in /cluster/www/www/www/kunzmann/vendor/symfony/class-loader/MapClassLoader.php on line 53 mstaab@mst18:/cluster/www/www/www/kunzmann$ ls /cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php /cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php php -r 'var_dump(stat("/cluster/www/www/www/kunzmann/app/shared/controllers/KMAccountController.php"));' array(26) { [0]=> int(51) [1]=> int(4474739) [2]=> int(33279) [3]=> int(1) [4]=> int(11226) [5]=> int(12128) [6]=> int(0) [7]=> int(23570) [8]=> int(1587720923) [9]=> int(1585235276) [10]=> int(1587720894) [11]=> int(262144) [12]=> int(48) ["dev"]=> int(51) ["ino"]=> int(4474739) ["mode"]=> int(33279) ["nlink"]=> int(1) ["uid"]=> int(11226) ["gid"]=> int(12128) ["rdev"]=> int(0) ["size"]=> int(23570) ["atime"]=> int(1587720923) ["mtime"]=> int(1585235276) ["ctime"]=> int(1587720894) ["blksize"]=> int(262144) ["blocks"]=> int(48) }