Make WordPress Core


Ignore:
Timestamp:
03/25/2011 02:42:20 AM (14 years ago)
Author:
dd32
Message:

First run of introducing Stream-To-File for the WP_HTTP API. Reduces memory consumption during file downloads. Implemented in download_url() for upgraders. Props sivel. See #16236

File:
1 edited

Legend:

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

    r17516 r17555  
    21092109
    21102110    return rtrim($base, '/') . '/' . ltrim($path, '/');
     2111}
     2112
     2113/**
     2114 * Determines a writable directory for temporary files.
     2115 * 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/
     2116 *
     2117 * 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.
     2118 *
     2119 * @since 2.5.0
     2120 *
     2121 * @return string Writable temporary directory
     2122 */
     2123function get_temp_dir() {
     2124    static $temp;
     2125    if ( defined('WP_TEMP_DIR') )
     2126        return trailingslashit(WP_TEMP_DIR);
     2127
     2128    if ( $temp )
     2129        return trailingslashit($temp);
     2130
     2131    $temp = WP_CONTENT_DIR . '/';
     2132    if ( is_dir($temp) && @is_writable($temp) )
     2133        return $temp;
     2134
     2135    if  ( function_exists('sys_get_temp_dir') ) {
     2136        $temp = sys_get_temp_dir();
     2137        if ( @is_writable($temp) )
     2138            return trailingslashit($temp);
     2139    }
     2140
     2141    $temp = ini_get('upload_tmp_dir');
     2142    if ( is_dir($temp) && @is_writable($temp) )
     2143        return trailingslashit($temp);
     2144
     2145    $temp = '/tmp/';
     2146    return $temp;
    21112147}
    21122148
Note: See TracChangeset for help on using the changeset viewer.