diff options
author | Justin Velluppillai <justin@innocraft.com> | 2022-03-09 00:03:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-09 00:03:18 +0300 |
commit | 7255b44b89f9c73b4d39a492902f4c56739fbc99 (patch) | |
tree | 0a790d97af2ddb8898e8b00ea75bb96df590a4f7 /core | |
parent | 680db1156be27769709bf9a6e7f67636e7cfb8dc (diff) |
Merge RC patches back to main branch (#18901)
* Update version to 4.8.0-rc1
* Fix possible warning in Url::isValidHost (#18887)
* Handle case only file name updates on case insensitive file systems (#18865)
* Added unit test for case-sensitive unlink
* Use case-insensitive comparison in directoryDiff() if a case-insensitive filesystem is detected
* Fix misleading method name
* Update tests/PHPUnit/Unit/FilesystemTest.php
Co-authored-by: Justin Velluppillai <justin@innocraft.com>
* Update tests/PHPUnit/Unit/FilesystemTest.php
Co-authored-by: Justin Velluppillai <justin@innocraft.com>
Co-authored-by: Justin Velluppillai <justin@innocraft.com>
* Update version to 4.8.0 (#18893)
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/Filesystem.php | 23 | ||||
-rw-r--r-- | core/Url.php | 4 | ||||
-rw-r--r-- | core/Version.php | 2 |
3 files changed, 25 insertions, 4 deletions
diff --git a/core/Filesystem.php b/core/Filesystem.php index 4a7e7de106..5b8101291f 100644 --- a/core/Filesystem.php +++ b/core/Filesystem.php @@ -314,7 +314,11 @@ class Filesystem return str_replace($target, '', $file); }, $targetFiles); - $diff = array_diff($targetFiles, $sourceFiles); + if (FileSystem::isFileSystemCaseInsensitive()) { + $diff = array_udiff($targetFiles, $sourceFiles, 'strcasecmp'); + } else { + $diff = array_diff($targetFiles, $sourceFiles); + } return array_values($diff); } @@ -558,6 +562,23 @@ class Filesystem } /** + * Check if the filesystem is case sensitive by writing a temporary file + * + * @return bool + */ + public static function isFileSystemCaseInsensitive() : bool + { + $testFileName = 'caseSensitivityTest.txt'; + $pathTmp = StaticContainer::get('path.tmp'); + @file_put_contents($pathTmp.'/'.$testFileName, 'Nothing to see here.'); + if (\file_exists($pathTmp.'/'.strtolower($testFileName))) { + // Wrote caseSensitivityTest.txt but casesensitivitytest.txt exists, so case insensitive + return true; + } + return false; + } + + /** * in tmp/ (sub-)folder(s) we create empty index.htm|php files * * @param $path diff --git a/core/Url.php b/core/Url.php index a79fdecb5b..c027538cdb 100644 --- a/core/Url.php +++ b/core/Url.php @@ -206,7 +206,7 @@ class Url * value from the request. * @return bool `true` if valid; `false` otherwise. */ - public static function isValidHost($host = false) + public static function isValidHost($host = false): bool { // only do trusted host check if it's enabled if (isset(Config::getInstance()->General['enable_trusted_host_check']) @@ -215,7 +215,7 @@ class Url return true; } - if ($host === false) { + if (false === $host || null === $host) { $host = self::getHostFromServerVariable(); if (empty($host)) { // if no current host, assume valid diff --git a/core/Version.php b/core/Version.php index a5a57de219..ad030d351e 100644 --- a/core/Version.php +++ b/core/Version.php @@ -20,7 +20,7 @@ final class Version * The current Matomo version. * @var string */ - const VERSION = '4.7.1'; + const VERSION = '4.8.0'; const MAJOR_VERSION = 4; |