Make WordPress Core

Changeset 22008


Ignore:
Timestamp:
09/26/2012 05:02:58 AM (14 years ago)
Author:
dd32
Message:

Rearrange the order that we check for temporary directories in get_temp_dir(). This change causes us to use System temporary directories in preference to WP_CONTENT_DIR, for better windows compatibility, we use win_is_writable() as well. Props simonwheatley and kurtpayne for initial patches, See #20778

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r21996 r22008  
    13681368/**
    13691369 * Determines a writable directory for temporary files.
    1370  * Function's preference is to WP_CONTENT_DIR followed by the return value of <code>sys_get_temp_dir()</code>, before finally defaulting to /tmp/
    1371  *
    1372  * In the event that this function does not find a writable location, It may be overridden by the <code>WP_TEMP_DIR</code> constant in your <code>wp-config.php</code> file.
     1370 * Function's preference is the return value of <code>sys_get_temp_dir()</code>,
     1371 * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR,
     1372 * before finally defaulting to /tmp/
     1373 *
     1374 * In the event that this function does not find a writable location,
     1375 * It may be overridden by the <code>WP_TEMP_DIR</code> constant in
     1376 * your <code>wp-config.php</code> file.
    13731377 *
    13741378 * @since 2.5.0
     
    13841388                return trailingslashit($temp);
    13851389
     1390        $is_win = ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) );
     1391
     1392        if ( function_exists('sys_get_temp_dir') ) {
     1393                $temp = sys_get_temp_dir();
     1394                if ( is_dir( $temp ) && ( $is_win ? win_is_writable( $temp ) : @is_writable( $temp ) ) ) {
     1395                        return trailingslashit( $temp );
     1396                }
     1397        }
     1398
     1399        $temp = ini_get('upload_tmp_dir');
     1400        if ( is_dir( $temp ) && ( $is_win ? win_is_writable( $temp ) : @is_writable( $temp ) ) )
     1401                return trailingslashit($temp);
     1402
    13861403        $temp = WP_CONTENT_DIR . '/';
    1387         if ( is_dir($temp) && @is_writable($temp) )
     1404        if ( is_dir( $temp ) && ( $is_win ? win_is_writable( $temp ) : @is_writable( $temp ) ) )
    13881405                return $temp;
    1389 
    1390         if  ( function_exists('sys_get_temp_dir') ) {
    1391                 $temp = sys_get_temp_dir();
    1392                 if ( @is_writable($temp) )
    1393                         return trailingslashit($temp);
    1394         }
    1395 
    1396         $temp = ini_get('upload_tmp_dir');
    1397         if ( is_dir($temp) && @is_writable($temp) )
    1398                 return trailingslashit($temp);
    13991406
    14001407        $temp = '/tmp/';
Note: See TracChangeset for help on using the changeset viewer.