WordPress.org

Make WordPress Core

Changeset 22009


Ignore:
Timestamp:
09/26/12 05:08:26 (3 years ago)
Author:
dd32
Message:

Move win_is_writable() from wp-admin/includes to wp-includes so that it's always available for get_temp_dir(). Fixes #20778

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/misc.php

    r21322 r22009  
    525525 
    526526/** 
    527  * Workaround for Windows bug in is_writable() function 
    528  * 
    529  * @since 2.8.0 
    530  * 
    531  * @param string $path 
    532  * @return bool 
    533  */ 
    534 function win_is_writable( $path ) { 
    535     /* will work in despite of Windows ACLs bug 
    536      * NOTE: use a trailing slash for folders!!! 
    537      * see http://bugs.php.net/bug.php?id=27609 
    538      * see http://bugs.php.net/bug.php?id=30931 
    539      */ 
    540  
    541     if ( $path[strlen( $path ) - 1] == '/' ) // recursively return a temporary file path 
    542         return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp'); 
    543     else if ( is_dir( $path ) ) 
    544         return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); 
    545     // check tmp file for read/write capabilities 
    546     $should_delete_tmp_file = !file_exists( $path ); 
    547     $f = @fopen( $path, 'a' ); 
    548     if ( $f === false ) 
    549         return false; 
    550     fclose( $f ); 
    551     if ( $should_delete_tmp_file ) 
    552         unlink( $path ); 
    553     return true; 
    554 } 
    555  
    556 /** 
    557527 * Display the default admin color scheme picker (Used in user-edit.php) 
    558528 * 
  • trunk/wp-includes/functions.php

    r22008 r22009  
    14071407    $temp = '/tmp/'; 
    14081408    return $temp; 
     1409} 
     1410 
     1411/** 
     1412 * Workaround for Windows bug in is_writable() function 
     1413 * 
     1414 * @since 2.8.0 
     1415 * 
     1416 * @param string $path 
     1417 * @return bool 
     1418 */ 
     1419function win_is_writable( $path ) { 
     1420    /* will work in despite of Windows ACLs bug 
     1421     * NOTE: use a trailing slash for folders!!! 
     1422     * see http://bugs.php.net/bug.php?id=27609 
     1423     * see http://bugs.php.net/bug.php?id=30931 
     1424     */ 
     1425 
     1426    if ( $path[strlen( $path ) - 1] == '/' ) // recursively return a temporary file path 
     1427        return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp'); 
     1428    else if ( is_dir( $path ) ) 
     1429        return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); 
     1430    // check tmp file for read/write capabilities 
     1431    $should_delete_tmp_file = !file_exists( $path ); 
     1432    $f = @fopen( $path, 'a' ); 
     1433    if ( $f === false ) 
     1434        return false; 
     1435    fclose( $f ); 
     1436    if ( $should_delete_tmp_file ) 
     1437        unlink( $path ); 
     1438    return true; 
    14091439} 
    14101440 
Note: See TracChangeset for help on using the changeset viewer.