Project

General

Profile

Actions

Bug #88524

closed

rmdir not respecting POSIX standard - missing files

Added by Pascal Christen over 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2019-06-07
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
CodingNight
Complexity:
Is Regression:
Sprint Focus:

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

Actions #1

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

Actions #2

Updated by Pascal Christen over 5 years ago

Anyone?

Actions #3

Updated by Susanne Moog over 5 years ago

  • Tags set to CodingNight
Actions #4

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

Actions #5

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

Actions #6

Updated by Anonymous over 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Benni Mack almost 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF