diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 7f0c2bf36ab..a396af6d40c 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1841,11 +1841,7 @@ function wfTimestampNow() { * @return bool True if it's Windows, false otherwise. */ function wfIsWindows() { - static $isWindows = null; - if ( $isWindows === null ) { - $isWindows = strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN'; - } - return $isWindows; + return PHP_OS_FAMILY === 'Windows'; } /** diff --git a/includes/libs/filebackend/FSFileBackend.php b/includes/libs/filebackend/FSFileBackend.php index 581b577f591..612ad4e35d3 100644 --- a/includes/libs/filebackend/FSFileBackend.php +++ b/includes/libs/filebackend/FSFileBackend.php @@ -77,7 +77,7 @@ class FSFileBackend extends FileBackendStore { /** @var string Required OS username to own files */ protected $fileOwner; - /** @var bool Simpler version of PHP_OS_FAMILY (PHP 7.2) */ + /** @var bool Simpler version of PHP_OS_FAMILY */ protected $os; /** @var string OS username running this script */ protected $currentUser; @@ -98,9 +98,9 @@ class FSFileBackend extends FileBackendStore { public function __construct( array $config ) { parent::__construct( $config ); - if ( substr( PHP_OS, 0, 3 ) === 'WIN' || PHP_OS === 'Windows' ) { + if ( PHP_OS_FAMILY === 'Windows' ) { $this->os = 'Windows'; - } elseif ( substr( PHP_OS, 0, -3 ) === 'BSD' || PHP_OS === 'Darwin' ) { + } elseif ( PHP_OS_FAMILY === 'BSD' || PHP_OS_FAMILY === 'Darwin' ) { $this->os = 'BSD'; } else { $this->os = 'Linux'; diff --git a/includes/libs/filebackend/fsfile/TempFSFile.php b/includes/libs/filebackend/fsfile/TempFSFile.php index 6f87438aea6..4d6f620c522 100644 --- a/includes/libs/filebackend/fsfile/TempFSFile.php +++ b/includes/libs/filebackend/fsfile/TempFSFile.php @@ -92,7 +92,7 @@ class TempFSFile extends FSFile { // the current process. // The user is included as if various scripts are run by different users they will likely // not be able to access each others temporary files. - if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) { + if ( PHP_OS_FAMILY === 'Windows' ) { $tmp = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mwtmp-' . get_current_user(); if ( !is_dir( $tmp ) ) { mkdir( $tmp ); diff --git a/includes/libs/lockmanager/FSLockManager.php b/includes/libs/lockmanager/FSLockManager.php index 86336d38cae..a901e1049db 100644 --- a/includes/libs/lockmanager/FSLockManager.php +++ b/includes/libs/lockmanager/FSLockManager.php @@ -60,7 +60,7 @@ class FSLockManager extends LockManager { parent::__construct( $config ); $this->lockDir = $config['lockDirectory']; - $this->isWindows = ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ); + $this->isWindows = ( PHP_OS_FAMILY === 'Windows' ); } /** diff --git a/includes/libs/uuid/GlobalIdGenerator.php b/includes/libs/uuid/GlobalIdGenerator.php index 428d15b196f..a8a74cf7d40 100644 --- a/includes/libs/uuid/GlobalIdGenerator.php +++ b/includes/libs/uuid/GlobalIdGenerator.php @@ -645,7 +645,7 @@ class GlobalIdGenerator { // Try to get some ID that uniquely identifies this machine (RFC 4122)... if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) { AtEase::suppressWarnings(); - if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) { + if ( PHP_OS_FAMILY === 'Windows' ) { // https://technet.microsoft.com/en-us/library/bb490913.aspx $csv = trim( ( $this->shellCallback )( 'getmac /NH /FO CSV' ) ); $line = substr( $csv, 0, strcspn( $csv, "\n" ) );