Use PHP_OS rather than php_uname, which may be disabled
authorOri Livneh <ori@wikimedia.org>
Wed, 28 Jan 2015 04:38:57 +0000 (20:38 -0800)
committerKrinkle <krinklemail@gmail.com>
Thu, 9 Apr 2015 12:16:17 +0000 (12:16 +0000)
A user just logged on to the #mediawiki channel to ask for help because his
webhost disallowed php_uname(), causing wfIsWindows() to crash. Google
autocompletes 'php_uname()' to 'php_uname() has been disabled for security
reasons', so it is probably not uncommon. Consulting the PHP_OS constant
instead side-steps the problem nicely.

Change-Id: I8d63826db4fc5d142eac53717d4f9fbbf9928de9

includes/GlobalFunctions.php

index 3be43b3..31bb099 100644 (file)
@@ -2459,7 +2459,7 @@ function wfTimestampNow() {
 function wfIsWindows() {
        static $isWindows = null;
        if ( $isWindows === null ) {
-               $isWindows = substr( php_uname(), 0, 7 ) == 'Windows';
+               $isWindows = strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN';
        }
        return $isWindows;
 }