Bug #88524
closedrmdir not respecting POSIX standard - missing files
100%
Description
Hi
Having a problem with typo3 and it's own written rmdir function: https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/Utility/GeneralUtility.php#L2105
POSIX standard says the following:
If a file is removed from or added to the directory after the most recent call to opendir() or rewinddir(), whether a subsequent call to readdir() returns an entry for that file is unspecified
So the problem is, that it doesn't return all files while deleting it - for more details read the issue about the same topic here: https://github.com/emscripten-core/emscripten/issues/2528
As a consequence, e.g. deleting extensions does not work because it did not delete all files.
Thanks, greetings Pascal
Updated by Pascal Christen over 5 years ago
So I just "rebuilt" the function:
showfiles.php <?php function removeFiles($path) { $handle = opendir($path); while (false !== ($file = readdir($handle))) { if ($file === '.' || $file === '..') { continue; } echo "PATH $path/$file\n"; #unlink($path . '/' . $file); } closedir($handle); } $path = realpath('/home/christes/test/'); removeFiles($path); So, I'm touching 200 new files in the directory /home/christes/test/ [christes@xxx:~/test] $ touch test{001..200}.test Now if I run the PHP-script without the unlink (commented out) - it's all fine: [christes@xxx:~] $ php listdir.php | wc -l 200 Now, if I remove the # in front of the ulink this happens: [christes@xxx:~] $ php listdir.php | wc -l 126 [christes@xxx:~] $ php listdir.php | wc -l 74 On the first round, it only removes the first 126 files, if I rerun it again it deletes the remaining files. And it deletes less files if the filename is longer: [christes@xxx:~/test] $ touch testtesttesttesttesttesttesttesttesttesttest{001..200}.test [christes@xxx:~] $ php listdir.php | wc -l 111
Updated by Gerrit Code Review over 5 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61408
Updated by Gerrit Code Review over 5 years ago
Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61364
Updated by Anonymous over 5 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 28d1f6af1df082052705d7d9cb813df099b52bbb.