WordPress.org

Make WordPress Core

Changeset 21822


Ignore:
Timestamp:
09/11/2012 10:06:49 PM (6 years ago)
Author:
nacin
Message:

Always return upload directory information from wp_upload_dir(), even if there is an error. Append the error to the array. see #19235.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r21818 r21822  
    14681468    }
    14691469
    1470     $bdir = $dir;
    1471     $burl = $url;
     1470    $basedir = $dir;
     1471    $baseurl = $url;
    14721472
    14731473    $subdir = '';
     
    14841484    $url .= $subdir;
    14851485
    1486     $uploads = apply_filters( 'upload_dir', array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false ) );
     1486    $uploads = apply_filters( 'upload_dir',
     1487        array(
     1488            'path'    => $dir,
     1489            'url'     => $url,
     1490            'subdir'  => $subdir,
     1491            'basedir' => $basedir,
     1492            'baseurl' => $baseurl,
     1493            'error'   => false,
     1494        ) );
    14871495
    14881496    // Make sure we have an uploads dir
    14891497    if ( ! wp_mkdir_p( $uploads['path'] ) ) {
    14901498        $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $uploads['path'] );
    1491         return array( 'error' => $message );
     1499        $uploads['error'] = $message;
    14921500    }
    14931501
  • trunk/wp-includes/post.php

    r21818 r21822  
    224224    $new_path = $path;
    225225
    226     if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) {
    227         if ( 0 === strpos($new_path, $uploads['basedir']) ) {
    228                 $new_path = str_replace($uploads['basedir'], '', $new_path);
    229                 $new_path = ltrim($new_path, '/');
    230         }
     226    $uploads = wp_upload_dir();
     227    if ( 0 === strpos( $new_path, $uploads['basedir'] ) ) {
     228            $new_path = str_replace( $uploads['basedir'], '', $new_path );
     229            $new_path = ltrim( $new_path, '/' );
    231230    }
    232231
Note: See TracChangeset for help on using the changeset viewer.