WordPress.org

Make WordPress Core

Changeset 38167


Ignore:
Timestamp:
07/27/2016 05:09:27 PM (3 years ago)
Author:
ocean90
Message:

Filesystem API: Output buffering for request_filesystem_credentials() should wrap the function directly.

Previously ob_end_clean() was only called when the previous condition was successful which led to unexpected results when another output buffering was involved, like PHPUnit's.

Fixes #37488.

Location:
trunk/src/wp-admin/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r38159 r38167  
    35163516    }
    35173517
    3518     // Check filesystem credentials. `delete_plugins()` will bail otherwise.
     3518    // Check filesystem credentials. `delete_theme()` will bail otherwise.
     3519    $url = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet );
    35193520    ob_start();
    3520     $url = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet );
    3521     if ( false === ( $credentials = request_filesystem_credentials( $url ) ) || ! WP_Filesystem( $credentials ) ) {
     3521    $credentials = request_filesystem_credentials( $url );
     3522    ob_end_clean();
     3523    if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
    35223524        global $wp_filesystem;
    3523         ob_end_clean();
    35243525
    35253526        $status['errorCode']    = 'unable_to_connect_to_filesystem';
     
    37723773
    37733774    // Check filesystem credentials. `delete_plugins()` will bail otherwise.
     3775    $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' );
    37743776    ob_start();
    3775     $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' );
    3776     if ( false === ( $credentials = request_filesystem_credentials( $url ) ) || ! WP_Filesystem( $credentials ) ) {
     3777    $credentials = request_filesystem_credentials( $url );
     3778    ob_end_clean();
     3779    if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
    37773780        global $wp_filesystem;
    3778         ob_end_clean();
    37793781
    37803782        $status['errorCode']    = 'unable_to_connect_to_filesystem';
  • trunk/src/wp-admin/includes/plugin.php

    r38074 r38167  
    783783        $checked[] = 'checked[]=' . $plugin;
    784784
     785    $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins');
     786
    785787    ob_start();
    786     $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins');
    787     if ( false === ($credentials = request_filesystem_credentials($url)) ) {
    788         $data = ob_get_clean();
    789 
     788    $credentials = request_filesystem_credentials( $url );
     789    $data = ob_get_clean();
     790
     791    if ( false === $credentials ) {
    790792        if ( ! empty($data) ){
    791793            include_once( ABSPATH . 'wp-admin/admin-header.php');
     
    797799    }
    798800
    799     if ( ! WP_Filesystem($credentials) ) {
    800         request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
     801    if ( ! WP_Filesystem( $credentials ) ) {
     802        ob_start();
     803        request_filesystem_credentials( $url, '', true ); // Failed to connect, Error and request again.
    801804        $data = ob_get_clean();
    802805
  • trunk/src/wp-admin/includes/theme.php

    r38082 r38167  
    2424        return false;
    2525
     26    if ( empty( $redirect ) ) {
     27        $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet);
     28    }
     29
    2630    ob_start();
    27     if ( empty( $redirect ) )
    28         $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet);
    29     if ( false === ($credentials = request_filesystem_credentials($redirect)) ) {
    30         $data = ob_get_clean();
    31 
    32         if ( ! empty($data) ){
     31    $credentials = request_filesystem_credentials( $redirect );
     32    $data = ob_get_clean();
     33
     34    if ( false === $credentials ) {
     35        if ( ! empty( $data ) ){
    3336            include_once( ABSPATH . 'wp-admin/admin-header.php');
    3437            echo $data;
     
    3942    }
    4043
    41     if ( ! WP_Filesystem($credentials) ) {
    42         request_filesystem_credentials($redirect, '', true); // Failed to connect, Error and request again
     44    if ( ! WP_Filesystem( $credentials ) ) {
     45        ob_start();
     46        request_filesystem_credentials( $redirect, '', true ); // Failed to connect, Error and request again.
    4347        $data = ob_get_clean();
    4448
Note: See TracChangeset for help on using the changeset viewer.