Issue #2911379 by Spokje, ProFire, mstrelan: Unneccessary bitwise operation for file permissions check on Windows

(cherry picked from commit 2b2aebcdee)
merge-requests/3234/head
Lee Rowlands 2023-03-30 16:19:34 +10:00
parent d4c8e5c3d5
commit 6a984c2648
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
1 changed files with 0 additions and 12 deletions

View File

@ -144,18 +144,6 @@ class FileSystemTest extends UnitTestCase {
protected function assertFilePermissions(int $expected_mode, string $uri, string $message = ''): void {
// Mask out all but the last three octets.
$actual_mode = fileperms($uri) & 0777;
// PHP on Windows has limited support for file permissions. Usually each of
// "user", "group" and "other" use one octal digit (3 bits) to represent the
// read/write/execute bits. On Windows, chmod() ignores the "group" and
// "other" bits, and fileperms() returns the "user" bits in all three
// positions. $expected_mode is updated to reflect this.
if (substr(PHP_OS, 0, 3) == 'WIN') {
// Reset the "group" and "other" bits.
$expected_mode = $expected_mode & 0700;
// Shift the "user" bits to the "group" and "other" positions also.
$expected_mode = $expected_mode | $expected_mode >> 3 | $expected_mode >> 6;
}
$this->assertSame($expected_mode, $actual_mode, $message);
}