|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-11-22 23:37 UTC] batonxleba at gmail dot com
Description:
------------
mkdir () does not create a subdirectory and generates an error when I try to create it in a directory that has the same name as the file that was deleted before this but any of the is_dir / file_exists / is_writable functions were applied to it.
if i comment line 5 in example below script will work fine.
my cli php
PHP 7.2.10 (cli) (built: Nov 10 2018 11:44:18) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10, Copyright (c) 1999-2018, by Zend Technologies
Test script:
---------------
#!/usr/bin/php
<?php
exec('> vpupkin');
if(is_dir('vpupkin'))print 'true'."\n";
exec('rm -f vpupkin');
mkdir('vpupkin',0700);
mkdir('vpupkin/'.date("d.m.Y"),0700);
?>
Actual result:
--------------
dev ~/testftp # rm -r vpupkin; ./t.php
PHP Warning: mkdir(): No such file or directory in /root/testftp/t.php on line 9
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 13:00:01 2025 UTC |
Other observations from a Win10 build consistent with the above: 1) clearstatcache() doesn't affect behaviour 2) Being Windows, using "del" instead of an "rm" port doesn't fix things. 3) a single mkdir('vpupkin/'.date("d.m.Y"), 0700, true) call fails in the same way as the two consecutive mkdirs() (vpupkin is created but can't be found to create the subdirectory within it). 4) using unlink() instead of exec('rm') does allow the subdirectory to be created.UPD: Using unlink() instead of exec('rm') solved the problem for me.The problem is that the realpathcache (the stat cache is irrelevant here) is not aware of the external change. Calling clearstatcache(true) after executing exec('rm -f vpupkin') solves that problem. So this is expected behavior, which is also documented on the clearstatcache() page[1]. [1] <https://www.php.net/clearstatcache>