diff options
author | Stefan Giehl <stefan@matomo.org> | 2021-12-06 00:43:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-06 00:43:41 +0300 |
commit | deebc02b97db63137688359c443829e969350106 (patch) | |
tree | 007bd3e98533a7d4d2cce50ccbaeaf6225f8e17c | |
parent | 061f578955758584ab79b79a5b6246a599061161 (diff) |
Remove hidden files on update on servers supporting GLOB_BRACE (#18447)
-rw-r--r-- | core/Filesystem.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/Filesystem.php b/core/Filesystem.php index ff7942190e..4a7e7de106 100644 --- a/core/Filesystem.php +++ b/core/Filesystem.php @@ -294,8 +294,17 @@ class Filesystem */ public static function directoryDiff($source, $target) { - $sourceFiles = self::globr($source, '*'); - $targetFiles = self::globr($target, '*'); + $flags = 0; + $pattern = '*'; + + if (defined('GLOB_BRACE')) { + // The GLOB_BRACE flag is not available on some non GNU systems, like Solaris or Alpine Linux. + $flags = GLOB_BRACE; + $pattern = '{,.}*[!.]*'; // matches all files and folders, including those starting with ".", but excludes "." and ".." + } + + $sourceFiles = self::globr($source, $pattern, $flags); + $targetFiles = self::globr($target, $pattern, $flags); $sourceFiles = array_map(function ($file) use ($source) { return str_replace($source, '', $file); |