Merge "Remove PHP < 5.3.6 compatibility in LegacyLogger"
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index f797e5b..4844531 100644 (file)
@@ -34,7 +34,7 @@ use MediaWiki\Session\SessionManager;
 /**
  * Compatibility functions
  *
- * We support PHP 5.3.3 and up.
+ * We support PHP 5.5.9 and up.
  * Re-implementations of newer functions or functions in non-standard
  * PHP extensions may be included here.
  */
@@ -92,19 +92,6 @@ if ( !function_exists( 'mb_strrpos' ) ) {
        }
 }
 
-// gzdecode function only exists in PHP >= 5.4.0
-// http://php.net/gzdecode
-if ( !function_exists( 'gzdecode' ) ) {
-       /**
-        * @codeCoverageIgnore
-        * @param string $data
-        * @return string
-        */
-       function gzdecode( $data ) {
-               return gzinflate( substr( $data, 10, -8 ) );
-       }
-}
-
 // hash_equals function only exists in PHP >= 5.6.0
 // http://php.net/hash_equals
 if ( !function_exists( 'hash_equals' ) ) {
@@ -1475,7 +1462,7 @@ function wfMsgReplaceArgs( $message, $args ) {
        $message = str_replace( "\r", '', $message );
 
        // Replace arguments
-       if ( count( $args ) ) {
+       if ( is_array( $args ) && $args ) {
                if ( is_array( $args[0] ) ) {
                        $args = array_values( $args[0] );
                }
@@ -2162,8 +2149,8 @@ function wfIsHHVM() {
 /**
  * Tries to get the system directory for temporary files. First
  * $wgTmpDirectory is checked, and then the TMPDIR, TMP, and TEMP
- * environment variables are then checked in sequence, and if none are
- * set try sys_get_temp_dir().
+ * environment variables are then checked in sequence, then
+ * sys_get_temp_dir(), then upload_tmp_dir from php.ini.
  *
  * NOTE: When possible, use instead the tmpfile() function to create
  * temporary files to avoid race conditions on file creation, etc.
@@ -2178,13 +2165,16 @@ function wfTempDir() {
        }
 
        $tmpDir = array_map( "getenv", array( 'TMPDIR', 'TMP', 'TEMP' ) );
+       $tmpDir[] = sys_get_temp_dir();
+       $tmpDir[] = ini_get( 'upload_tmp_dir' );
 
        foreach ( $tmpDir as $tmp ) {
                if ( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) {
                        return $tmp;
                }
        }
-       return sys_get_temp_dir();
+       throw new MWException( 'No writable temporary directory could be found. ' .
+               'Please set $wgTmpDirectory to a writable directory.' );
 }
 
 /**
@@ -3079,7 +3069,6 @@ function wfSetupSession( $sessionId = false ) {
        if ( session_id() !== $session->getId() ) {
                session_id( $session->getId() );
        }
-
        MediaWiki\quietCall( 'session_start' );
 }