WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/30/2019 11:00:30 AM (3 years ago)
Author:
flixos90
Message:

Bootstrap/Load: Revert fatal error recovery mechanism from 5.1 to polish for 5.2.

Due to the high number of follow-up tickets and associated security concerns, it was decided to reschedule the fatal error recovery feature for WordPress 5.2, in order to address these issues properly. The feature will continue to be developed, with iterations being merged into trunk early in the 5.2 release cycle.

Fixes #46141. See #44458, #45932, #45940, #46038, #46047, #46068.

File:
1 edited

Legend:

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

    r44675 r44717  
    769769    <?php
    770770}
    771 
    772 /**
    773  * Determines whether a theme is technically active but was paused while
    774  * loading.
    775  *
    776  * For more information on this and similar theme functions, check out
    777  * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
    778  * Conditional Tags} article in the Theme Developer Handbook.
    779  *
    780  * @since 5.1.0
    781  *
    782  * @param string $theme Path to the theme directory relative to the themes directory.
    783  * @return bool True, if in the list of paused themes. False, not in the list.
    784  */
    785 function is_theme_paused( $theme ) {
    786     if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
    787         return false;
    788     }
    789 
    790     if ( $theme !== get_stylesheet() && $theme !== get_template() ) {
    791         return false;
    792     }
    793 
    794     return array_key_exists( $theme, $GLOBALS['_paused_themes'] );
    795 }
    796 
    797 /**
    798  * Gets the error that was recorded for a paused theme.
    799  *
    800  * @since 5.1.0
    801  *
    802  * @param string $theme Path to the theme directory relative to the themes
    803  *                      directory.
    804  * @return array|false Array of error information as it was returned by
    805  *                     `error_get_last()`, or false if none was recorded.
    806  */
    807 function wp_get_theme_error( $theme ) {
    808     if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
    809         return false;
    810     }
    811 
    812     if ( ! array_key_exists( $theme, $GLOBALS['_paused_themes'] ) ) {
    813         return false;
    814     }
    815 
    816     return $GLOBALS['_paused_themes'][ $theme ];
    817 }
    818 
    819 /**
    820  * Gets the number of sites on which a specific theme is paused.
    821  *
    822  * @since 5.1.0
    823  *
    824  * @param string $theme Path to the theme directory relative to the themes directory.
    825  * @return int Site count.
    826  */
    827 function count_paused_theme_sites_for_network( $theme ) {
    828     if ( ! is_multisite() ) {
    829         return is_theme_paused( $theme ) ? 1 : 0;
    830     }
    831 
    832     $query_args = array(
    833         'count'      => true,
    834         'number'     => 0,
    835         'network_id' => get_current_network_id(),
    836         'meta_query' => array(
    837             wp_paused_themes()->get_site_meta_query_clause( $theme ),
    838         ),
    839     );
    840 
    841     return get_sites( $query_args );
    842 }
    843 
    844 /**
    845  * Tries to resume a single theme.
    846  *
    847  * @since 5.1.0
    848  *
    849  * @param string $theme Single theme to resume.
    850  * @return bool|WP_Error True on success, false if `$theme` was not paused,
    851  *                       `WP_Error` on failure.
    852  */
    853 function resume_theme( $theme ) {
    854     $result = wp_forget_extension_error( 'themes', $theme );
    855 
    856     if ( ! $result ) {
    857         return new WP_Error(
    858             'could_not_resume_theme',
    859             __( 'Could not resume the theme.' )
    860         );
    861     }
    862 
    863     return true;
    864 }
    865 
    866 /**
    867  * Renders an admin notice in case some themes have been paused due to errors.
    868  *
    869  * @since 5.1.0
    870  */
    871 function paused_themes_notice() {
    872     if ( 'themes.php' === $GLOBALS['pagenow'] ) {
    873         return;
    874     }
    875 
    876     if ( ! current_user_can( 'switch_themes' ) ) {
    877         return;
    878     }
    879 
    880     if ( ! isset( $GLOBALS['_paused_themes'] ) || empty( $GLOBALS['_paused_themes'] ) ) {
    881         return;
    882     }
    883 
    884     printf(
    885         '<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p>%s</p></div>',
    886         __( 'One or more themes failed to load properly.' ),
    887         __( 'You can find more details and make changes on the Themes screen.' ),
    888         sprintf(
    889             '<a href="%s">%s</a>',
    890             admin_url( 'themes.php' ),
    891             'Go to the Themes screen'
    892         )
    893     );
    894 }
Note: See TracChangeset for help on using the changeset viewer.