Issue #2911379 by Spokje, ProFire, mstrelan: Unneccessary bitwise operation for file permissions check on Windows
(cherry picked from commit 2b2aebcdee
)
merge-requests/3234/head
parent
d4c8e5c3d5
commit
6a984c2648
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue