Make WordPress Core

Changeset 58139

Timestamp:
05/13/2024 03:22:07 PM (3 months ago)
Author:
johnbillion
Message:

Bootstrap/Load: Place the debugging output for automatic plugin and theme updates behind a debugging flag.

This change means this debugging output will only be shown when both the WP_DEBUG and WP_DEBUG_LOG constants are defined as true.

Props costdev, afragen, swissspidy

Fixes #58281

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-automatic-updater.php

    r58128 r58139  
    447447        }
    448448
     449
    449450        if ( 'plugin' === $type ) {
    450451            $was_active = is_plugin_active( $upgrader_item );
    451             error_log( '    Upgrading plugin ' . var_export( $item->slug, true ) . '...' );
    452         }
    453 
    454         if ( 'theme' === $type ) {
     452            if ( $is_debug ) {
     453                error_log( '    Upgrading plugin ' . var_export( $item->slug, true ) . '...' );
     454            }
     455        }
     456
     457        if ( 'theme' === $type && $is_debug ) {
    455458            error_log( '    Upgrading theme ' . var_export( $item->theme, true ) . '...' );
    456459        }
    ��  
    521524        }
    522525
    523         if ( 'theme' === $type ) {
     526        $is_debug = WP_DEBUG && WP_DEBUG_LOG;
     527
     528        if ( 'theme' === $type && $is_debug ) {
    524529            error_log( '    Theme ' . var_export( $item->theme, true ) . ' has been upgraded.' );
    525530        }
    526531
    527532        if ( 'plugin' === $type ) {
    528             error_log( '    Plugin ' . var_export( $item->slug, true ) . ' has been upgraded.' );
    529             if ( is_plugin_inactive( $upgrader_item ) ) {
    530                 error_log( '    ' . var_export( $upgrader_item, true ) . ' is inactive and will not be checked for fatal errors.' );
     533            if ( $is_debug ) {
     534                error_log( '    Plugin ' . var_export( $item->slug, true ) . ' has been upgraded.' );
     535                if ( is_plugin_inactive( $upgrader_item ) ) {
     536                    error_log( '    ' . var_export( $upgrader_item, true ) . ' is inactive and will not be checked for fatal errors.' );
     537                }
    531538            }
    532539
     
    597604                     * appear above this entry in the log file.
    598605                     */
    599                     error_log( '    ' . implode( "\n", $upgrade_result->get_error_messages() ) );
    600                 } else {
     606                    if ( $is_debug ) {
     607                        error_log( '    ' . implode( "\n", $upgrade_result->get_error_messages() ) );
     608                    }
     609                } elseif ( $is_debug ) {
    601610                    error_log( '    The update for ' . var_export( $item->slug, true ) . ' has no fatal errors.' );
    602611                }
     
    635644        }
    636645
    637         error_log( 'Automatic updates starting...' );
     646        $is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;
     647
     648        if ( $is_debug ) {
     649            error_log( 'Automatic updates starting...' );
     650        }
    638651
    639652        // Don't automatically run these things, as we'll handle it ourselves.
     
    647660        $plugin_updates = get_site_transient( 'update_plugins' );
    648661        if ( $plugin_updates && ! empty( $plugin_updates->response ) ) {
    649             error_log( '  Automatic plugin updates starting...' );
     662            if ( $is_debug ) {
     663                error_log( '  Automatic plugin updates starting...' );
     664            }
    650665
    651666            foreach ( $plugin_updates->response as $plugin ) {
     
    656671            wp_clean_plugins_cache();
    657672
    658             error_log( '  Automatic plugin updates complete.' );
     673            if ( $is_debug ) {
     674                error_log( '  Automatic plugin updates complete.' );
     675            }
    659676        }
    660677
     
    663680        $theme_updates = get_site_transient( 'update_themes' );
    664681        if ( $theme_updates && ! empty( $theme_updates->response ) ) {
    665             error_log( '  Automatic theme updates starting...' );
     682            if ( $is_debug ) {
     683                error_log( '  Automatic theme updates starting...' );
     684            }
    666685
    667686            foreach ( $theme_updates->response as $theme ) {
     
    671690            wp_clean_themes_cache();
    672691
    673             error_log( '  Automatic theme updates complete.' );
    674         }
    675 
    676         error_log( 'Automatic updates complete.' );
     692            if ( $is_debug ) {
     693                error_log( '  Automatic theme updates complete.' );
     694            }
     695        }
     696
     697        if ( $is_debug ) {
     698            error_log( 'Automatic updates complete.' );
     699        }
    677700
    678701        // Next, process any core update.
     
    17351758        $timeout = 50; // 50 seconds.
    17361759
    1737         error_log( '    Scraping home page...' );
     1760        $is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;
     1761        if ( $is_debug ) {
     1762            error_log( '    Scraping home page...' );
     1763        }
    17381764
    17391765        $needle_start = "###### wp_scraping_result_start:$scrape_key ######";
     
    17431769
    17441770        if ( is_wp_error( $response ) ) {
    1745             error_log( 'Loopback request failed: ' . $response->get_error_message() );
     1771            if ( $is_debug ) {
     1772                error_log( 'Loopback request failed: ' . $response->get_error_message() );
     1773            }
    17461774            return true;
    17471775        }
    17481776
    17491777        // If this outputs `true` in the log, it means there were no fatal errors detected.
    1750         error_log( var_export( substr( $response['body'], strpos( $response['body'], '###### wp_scraping_result_start:' ) ), true ) );
     1778        if ( $is_debug ) {
     1779            error_log( var_export( substr( $response['body'], strpos( $response['body'], '###### wp_scraping_result_start:' ) ), true ) );
     1780        }
    17511781
    17521782        $body                   = wp_remote_retrieve_body( $response );
Note: See TracChangeset for help on using the changeset viewer.