Ticket #44458: 44458-3.diff
File 44458-3.diff, 23.0 KB (added by , 7 years ago) |
---|
-
src/wp-admin/css/list-tables.css
diff --git src/wp-admin/css/list-tables.css src/wp-admin/css/list-tables.css index 8d78983993..3b0f9532ed 100644
ul.cat-checklist { 1301 1301 text-decoration: underline; 1302 1302 } 1303 1303 1304 .plugins tr.paused th.check-column { 1305 border-left: 4px solid #d54e21; 1306 } 1307 1308 .plugins tr.paused th, 1309 .plugins tr.paused td { 1310 background-color: #fef7f1; 1311 } 1312 1313 .plugins tr.paused .plugin-title, 1314 .plugins .paused .dashicons-warning { 1315 color: #dc3232; 1316 } 1317 1318 .plugins .paused .error-display p, 1319 .plugins .paused .error-display code { 1320 font-size: 90%; 1321 font-style: italic; 1322 color: rgb( 0, 0, 0, 0.7 ); 1323 } 1324 1325 .plugins .resume-link { 1326 color: #dc3232; 1327 } 1328 1304 1329 .plugin-card .update-now:before { 1305 1330 color: #f56e28; 1306 1331 content: "\f463"; -
src/wp-admin/includes/admin-filters.php
diff --git src/wp-admin/includes/admin-filters.php src/wp-admin/includes/admin-filters.php index bfc9f51cfc..0686b9b8c2 100644
add_action( 'load-plugins.php', 'wp_plugin_update_rows', 20 ); // After wp_updat 119 119 add_action( 'load-themes.php', 'wp_theme_update_rows', 20 ); // After wp_update_themes() is called. 120 120 121 121 add_action( 'admin_notices', 'update_nag', 3 ); 122 add_action( 'admin_notices', 'paused_plugins_notice', 5 ); 122 123 add_action( 'admin_notices', 'maintenance_nag', 10 ); 123 124 124 125 add_filter( 'update_footer', 'core_update_footer' ); -
src/wp-admin/includes/class-wp-plugins-list-table.php
diff --git src/wp-admin/includes/class-wp-plugins-list-table.php src/wp-admin/includes/class-wp-plugins-list-table.php index 6e130f94b4..ae82e78037 100644
class WP_Plugins_List_Table extends WP_List_Table { 40 40 ); 41 41 42 42 $status = 'all'; 43 if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) {43 if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused' ) ) ) { 44 44 $status = $_REQUEST['plugin_status']; 45 45 } 46 46 … … class WP_Plugins_List_Table extends WP_List_Table { 99 99 'upgrade' => array(), 100 100 'mustuse' => array(), 101 101 'dropins' => array(), 102 'paused' => array(), 102 103 ); 103 104 104 105 $screen = $this->screen; … … class WP_Plugins_List_Table extends WP_List_Table { 209 210 if ( $show_network_active ) { 210 211 // On the non-network screen, show network-active plugins if allowed 211 212 $plugins['active'][ $plugin_file ] = $plugin_data; 213 if ( is_plugin_paused( $plugin_file ) ) { 214 $plugins['paused'][ $plugin_file ] = $plugin_data; 215 } 212 216 } else { 213 217 // On the non-network screen, filter out network-active plugins 214 218 unset( $plugins['all'][ $plugin_file ] ); … … class WP_Plugins_List_Table extends WP_List_Table { 218 222 // On the non-network screen, populate the active list with plugins that are individually activated 219 223 // On the network-admin screen, populate the active list with plugins that are network activated 220 224 $plugins['active'][ $plugin_file ] = $plugin_data; 225 if ( is_plugin_paused( $plugin_file ) ) { 226 $plugins['paused'][ $plugin_file ] = $plugin_data; 227 } 221 228 } else { 222 229 if ( isset( $recently_activated[ $plugin_file ] ) ) { 223 230 // Populate the recently activated list with plugins that have been recently activated … … class WP_Plugins_List_Table extends WP_List_Table { 436 443 case 'dropins': 437 444 $text = _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count ); 438 445 break; 446 case 'paused': 447 $text = _n( 'Paused <span class="count">(%s)</span>', 'Paused <span class="count">(%s)</span>', $count ); 448 break; 439 449 case 'upgrade': 440 450 $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count ); 441 451 break; … … class WP_Plugins_List_Table extends WP_List_Table { 647 657 /* translators: %s: plugin name */ 648 658 $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Deactivate' ) . '</a>'; 649 659 } 660 if ( current_user_can( 'resume_plugin' ) && is_plugin_paused( $plugin_file ) ) { 661 /* translators: %s: plugin name */ 662 $actions['resume'] = '<a class="resume-link" href="' . wp_nonce_url( 'plugins.php?action=resume&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'resume-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Resume execution of %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Resume execution' ) . '</a>'; 663 } 650 664 } else { 651 665 if ( current_user_can( 'activate_plugin', $plugin_file ) ) { 652 666 /* translators: %s: plugin name */ … … class WP_Plugins_List_Table extends WP_List_Table { 753 767 $class .= ' update'; 754 768 } 755 769 770 $paused = is_plugin_paused( $plugin_file ); 771 if ( $paused ) { 772 $class .= ' paused'; 773 } 774 756 775 $plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name ); 757 776 printf( 758 777 '<tr class="%s" data-slug="%s" data-plugin="%s">', … … class WP_Plugins_List_Table extends WP_List_Table { 831 850 * @param array $plugin_data An array of plugin data. 832 851 * @param string $status Status of the plugin. Defaults are 'All', 'Active', 833 852 * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', 834 * 'Drop-ins', 'Search' .853 * 'Drop-ins', 'Search', 'Paused' 835 854 */ 836 855 $plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status ); 837 856 echo implode( ' | ', $plugin_meta ); 838 857 839 echo '</div></td>'; 858 echo '</div>'; 859 860 if ( $paused ) { 861 echo sprintf( 862 '<p><span class="dashicons dashicons-warning"></span> <strong>%s</strong></p>', 863 __( 'This plugin failed to load properly and was paused within the admin backend.' ) 864 ); 865 866 $error = wp_get_plugin_error( $plugin_file ); 867 868 if ( false !== $error ) { 869 $error['type'] = array_flip( array_slice( 870 get_defined_constants( true )['Core'], 871 1, 872 15, 873 true 874 ) )[ $error['type'] ]; 875 876 echo sprintf( 877 '<div class="error-display"><p>%s</p></div>', 878 sprintf( 879 __( 'The plugin caused an error of type %1$s in line %2$s of the file %3$s. Error message: %4$s' ), 880 "<code>{$error['type']}</code>", 881 "<code>{$error['line']}</code>", 882 "<code>{$error['file']}</code>", 883 "<code>{$error['message']}</code>" 884 ) 885 ); 886 } 887 } 888 889 890 echo '</td>'; 840 891 break; 841 892 default: 842 893 $classes = "$column_name column-$column_name $class"; … … class WP_Plugins_List_Table extends WP_List_Table { 869 920 * @param array $plugin_data An array of plugin data. 870 921 * @param string $status Status of the plugin. Defaults are 'All', 'Active', 871 922 * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', 872 * 'Drop-ins', 'Search' .923 * 'Drop-ins', 'Search', 'Paused'. 873 924 */ 874 925 do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status ); 875 926 … … class WP_Plugins_List_Table extends WP_List_Table { 885 936 * @param array $plugin_data An array of plugin data. 886 937 * @param string $status Status of the plugin. Defaults are 'All', 'Active', 887 938 * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', 888 * 'Drop-ins', 'Search' .939 * 'Drop-ins', 'Search', 'Paused' 889 940 */ 890 941 do_action( "after_plugin_row_{$plugin_file}", $plugin_file, $plugin_data, $status ); 891 942 } -
src/wp-admin/includes/plugin.php
diff --git src/wp-admin/includes/plugin.php src/wp-admin/includes/plugin.php index c898fc5169..7ac3fbf3c9 100644
function _get_dropins() { 444 444 'install.php' => array( __( 'Custom installation script.' ), true ), // auto on installation 445 445 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance 446 446 'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load 447 'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // auto on error 448 'shutdown-handler' => array( __( 'Custom PHP shutdown handler.' ), true ), // auto on error 447 449 ); 448 450 449 451 if ( is_multisite() ) { … … function is_plugin_inactive( $plugin ) { 496 498 return ! is_plugin_active( $plugin ); 497 499 } 498 500 501 /** 502 * Determines whether a plugin is technically active but was paused while 503 * loading. 504 * 505 * For more information on this and similar theme functions, check out 506 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 507 * Conditional Tags} article in the Theme Developer Handbook. 508 * 509 * @since 5.0.0 510 * 511 * @param string $plugin Path to the plugin file relative to the plugins directory. 512 * @return bool True, if in the active plugins list. False, not in the list. 513 */ 514 function is_plugin_paused( $plugin ) { 515 if ( ! isset( $GLOBALS['_paused_plugins'] ) ) { 516 return false; 517 } 518 519 if ( ! is_plugin_active( $plugin ) || is_plugin_active_for_network( $plugin ) ) { 520 return false; 521 } 522 523 list( $plugin ) = explode( '/', $plugin ); 524 525 return array_key_exists( $plugin, $GLOBALS['_paused_plugins'] ); 526 } 527 528 /** 529 * Gets the error that was recorded for a paused plugin. 530 * 531 * @since 5.0.0 532 * 533 * @param string $plugin Path to the plugin file relative to the plugins 534 * directory. 535 * @return array|false Array of error information as it was returned by 536 * `error_get_last()`, or false if none was recorded. 537 */ 538 function wp_get_plugin_error( $plugin ) { 539 if ( ! isset( $GLOBALS['_paused_plugins'] ) ) { 540 return false; 541 } 542 543 list( $plugin ) = explode( '/', $plugin ); 544 545 if ( ! array_key_exists( $plugin, $GLOBALS['_paused_plugins'] ) ) { 546 return false; 547 } 548 549 return $GLOBALS['_paused_plugins'][ $plugin ]; 550 } 551 499 552 /** 500 553 * Determines whether the plugin is active for the entire network. 501 554 * … … function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) { 693 746 continue; 694 747 } 695 748 749 // Clean up the database before deactivating the plugin. 750 if ( is_plugin_paused( $plugin ) ) { 751 resume_plugin( $plugin ); 752 } 753 696 754 $network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin ); 697 755 698 756 if ( ! $silent ) { … … function delete_plugins( $plugins, $deprecated = '' ) { 887 945 uninstall_plugin( $plugin_file ); 888 946 } 889 947 948 // Clean up the database before removing the plugin. 949 if ( is_plugin_paused( $plugin_file ) ) { 950 resume_plugin( $plugin_file ); 951 } 952 890 953 /** 891 954 * Fires immediately before a plugin deletion attempt. 892 955 * … … function delete_plugins( $plugins, $deprecated = '' ) { 959 1022 return true; 960 1023 } 961 1024 1025 /** 1026 * Resumes a single plugin. 1027 * 1028 * Resuming the plugin basically means removing its entry from the 1029 * `pause_on_admin` database option. 1030 * 1031 * @since 5.0.0 1032 * 1033 * @param string $plugin Single plugin to resume. 1034 * 1035 * @return bool|WP_Error True on success, false if `$plugin` was not paused, `WP_Error` on failure. 1036 */ 1037 function resume_plugin( $plugin ) { 1038 $result = wp_forget_extension_error( 'plugins', $plugin ); 1039 1040 if ( ! $result ) { 1041 return new WP_Error( 'could_not_resume_plugin', __( 'Could not resume execution of the plugin.' ) ); 1042 } 1043 1044 return true; 1045 } 1046 962 1047 /** 963 1048 * Validate active plugins 964 1049 * … … function wp_add_privacy_policy_content( $plugin_name, $policy_text ) { 2066 2151 2067 2152 WP_Privacy_Policy_Content::add( $plugin_name, $policy_text ); 2068 2153 } 2154 2155 /** 2156 * Renders an admin notice in case some plugins have been paused due to errors. 2157 * 2158 * @since 5.0.0 2159 * 2160 * @return void 2161 */ 2162 function paused_plugins_notice() { 2163 if ( 'plugins.php' === $GLOBALS['pagenow'] ) { 2164 return; 2165 } 2166 2167 if ( ! current_user_can( 'deactivate_plugins' ) ) { 2168 return; 2169 } 2170 2171 if ( ! isset( $GLOBALS['_paused_plugins'] ) || empty( $GLOBALS['_paused_plugins'] ) ) { 2172 return; 2173 } 2174 2175 2176 echo sprintf( 2177 '<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p>%s</p></div>', 2178 __( 'One or more plugins failed to load properly.' ), 2179 __( 'You can find more details and make changes on the Plugins screen.' ), 2180 sprintf( 2181 '<a href="%s">%s</a>', 2182 admin_url( 'plugins.php?plugin_status=paused' ), 2183 'Go to the Plugins screen' 2184 ) 2185 ); 2186 } -
src/wp-admin/plugins.php
diff --git src/wp-admin/plugins.php src/wp-admin/plugins.php index b482f474c0..b21254adc9 100644
if ( $action ) { 389 389 } 390 390 break; 391 391 392 case 'resume': 393 if ( ! current_user_can( 'resume_plugin', $plugin ) ) { 394 wp_die( __( 'Sorry, you are not allowed to resume execution of this plugin.' ) ); 395 } 396 397 if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) { 398 wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); 399 exit; 400 } 401 402 check_admin_referer( 'resume-plugin_' . $plugin ); 403 404 $result = resume_plugin( $plugin ); 405 406 if ( is_wp_error( $result ) ) { 407 wp_die( $result ); 408 } 409 410 wp_redirect( self_admin_url( "plugins.php?resume=true&plugin_status=$status&paged=$page&s=$s" ) ); 411 exit; 412 392 413 default: 393 414 if ( isset( $_POST['checked'] ) ) { 394 415 check_admin_referer( 'bulk-plugins' ); … … elseif ( isset( $_GET['deleted'] ) ) : 532 553 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins <strong>deactivated</strong>.' ); ?></p></div> 533 554 <?php elseif ( 'update-selected' == $action ) : ?> 534 555 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins are up to date.' ); ?></p></div> 556 <?php elseif ( isset( $_GET['resume'] ) ) : ?> 557 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Execution of plugin <strong>resumed</strong>.' ); ?></p></div> 535 558 <?php endif; ?> 536 559 537 560 <div class="wrap"> -
src/wp-includes/capabilities.php
diff --git src/wp-includes/capabilities.php src/wp-includes/capabilities.php index 592995a120..315ae6e556 100644
function map_meta_cap( $cap, $user_id ) { 455 455 case 'deactivate_plugins': 456 456 case 'activate_plugin': 457 457 case 'deactivate_plugin': 458 case 'resume_plugin': 458 459 $caps[] = 'activate_plugins'; 459 460 if ( is_multisite() ) { 460 461 // update_, install_, and delete_ are handled above with is_super_admin(). -
src/wp-includes/load.php
diff --git src/wp-includes/load.php src/wp-includes/load.php index 81014fdde8..183d460e00 100644
function wp_get_active_and_valid_plugins() { 687 687 $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; 688 688 } 689 689 } 690 691 /* 692 * Remove plugins from the list of active plugins when we're on an admin or 693 * login screen and the plugin appears in the `pause_on_admin` list. 694 */ 695 if ( 'wp-login.php' === $GLOBALS['pagenow'] 696 || ( is_admin() && ! wp_doing_ajax() ) ) { 697 $pause_on_admin = (array) get_option( 'pause_on_admin', array() ); 698 699 if ( ! array_key_exists( 'plugins', $pause_on_admin ) ) { 700 return $plugins; 701 } 702 703 foreach ( $plugins as $index => $plugin ) { 704 $parts = explode( 705 '/', 706 str_replace( WP_CONTENT_DIR . '/', '', $plugin ) 707 ); 708 709 $type = array_shift( $parts ); 710 $plugin = array_shift( $parts ); 711 712 if ( array_key_exists( $plugin, $pause_on_admin[ $type ] ) ) { 713 unset( $plugins[ $index ] ); 714 // Store list of paused plugins for displaying an admin notice. 715 $GLOBALS['_paused_plugins'][ $plugin ] = $pause_on_admin[ $type ][ $plugin ]; 716 } 717 } 718 } 719 690 720 return $plugins; 691 721 } 692 722 … … function wp_finalize_scraping_edited_file_errors( $scrape_key ) { 1250 1280 } 1251 1281 echo "\n###### wp_scraping_result_end:$scrape_key ######\n"; 1252 1282 } 1283 1284 /** 1285 * Prunes the array of recorded extension errors. 1286 * 1287 * @since 5.0.0 1288 * 1289 * @param array $errors Array of errors to prune. 1290 * @return array Pruned array of errors. 1291 */ 1292 function wp_prune_extension_errors( $errors ) { 1293 foreach( array( 'plugins', 'mu-plugins', 'themes' ) as $type ) { 1294 if ( ! array_key_exists( $type, $errors ) ) { 1295 continue; 1296 } 1297 1298 switch( $type ) { 1299 case 'plugins': 1300 $active_plugins = array_merge( 1301 (array) get_option( 'active_plugins', array() ), 1302 (array) get_option( 'active_sitewide_plugins', array() ) 1303 ); 1304 1305 foreach( $errors[ $type ] as $plugin => $error ) { 1306 $found = false; 1307 1308 foreach ( $active_plugins as $active_plugin ) { 1309 list( $active_plugin ) = explode( '/', $active_plugin ); 1310 1311 if ( $active_plugin === $plugin ) { 1312 $found = true; 1313 break; 1314 } 1315 } 1316 1317 if ( ! $found ) { 1318 unset( $errors[ $type ][ $plugin ] ); 1319 } 1320 } 1321 1322 break; 1323 case 'mu-plugins': 1324 // TODO: Implement theme-specific behavior. 1325 break; 1326 case 'themes': 1327 // TODO: Implement theme-specific behavior. 1328 break; 1329 } 1330 1331 if ( 0 === count( $errors[ $type ] ) ) { 1332 unset( $errors[ $type ] ); 1333 } 1334 } 1335 1336 return $errors; 1337 } 1338 1339 /** 1340 * Records the extension error as a database option. 1341 * 1342 * @since 5.0.0 1343 * 1344 * @param array $error Error that was triggered. 1345 * @return bool Whether the error was correctly recorded. 1346 */ 1347 function wp_record_extension_error( $error ) { 1348 $path = str_replace( WP_CONTENT_DIR . '/', '', $error['file'] ); 1349 1350 $parts = explode( '/', $path ); 1351 $type = array_shift( $parts ); 1352 $extension = array_shift( $parts ); 1353 1354 $errors = (array) get_option( 'pause_on_admin', array() ); 1355 1356 $modified_errors = $errors; 1357 1358 if ( ! array_key_exists( $type, $modified_errors ) ) { 1359 $modified_errors[ $type ] = array(); 1360 } 1361 1362 $modified_errors[ $type ][ $extension ] = $error; 1363 1364 $modified_errors = wp_prune_extension_errors( $modified_errors ); 1365 1366 if ( $modified_errors === $errors ) { 1367 return true; 1368 } 1369 1370 return update_option( 'pause_on_admin', $modified_errors ); 1371 } 1372 1373 /** 1374 * Forgets a previously recorded extension error again. 1375 * 1376 * @since 5.0.0 1377 * 1378 * @param string $type Type of the extension. 1379 * @param string $extension Relative path of the extension. 1380 * @return bool Whether the extension error was successfully forgotten. 1381 */ 1382 function wp_forget_extension_error( $type, $extension ) { 1383 $errors = (array) get_option( 'pause_on_admin', array() ); 1384 1385 if ( ! array_key_exists( $type, $errors ) ) { 1386 return false; 1387 } 1388 1389 $modified_errors = $errors; 1390 1391 switch ( $type ) { 1392 case 'plugins': 1393 list( $extension ) = explode( '/', $extension ); 1394 } 1395 1396 if ( array_key_exists( $extension, $errors[ $type ] ) ) { 1397 unset( $errors[ $type ][ $extension ] ); 1398 } 1399 1400 $modified_errors = wp_prune_extension_errors( $modified_errors ); 1401 1402 if ( $modified_errors === $errors ) { 1403 return true; 1404 } 1405 1406 return update_option( 'pause_on_admin', $modified_errors ); 1407 } 1408 1409 /** 1410 * Wraps the shutdown handler function so it can be made pluggable at a later 1411 * stage. 1412 * 1413 * @since 5.0.0 1414 * 1415 * @return void 1416 */ 1417 function wp_shutdown_handler_wrapper() { 1418 if ( defined( 'WP_EXECUTION_SUCCEEDED' ) && WP_EXECUTION_SUCCEEDED ) { 1419 return; 1420 } 1421 1422 // Load the pluggable shutdown handler in case we found one. 1423 if ( function_exists( 'wp_handle_shutdown' ) ) { 1424 $stop_propagation = (bool) wp_handle_shutdown(); 1425 1426 if ( $stop_propagation ) { 1427 return; 1428 } 1429 } 1430 1431 $error = error_get_last(); 1432 1433 // No error, just skip the error handling code. 1434 if ( null === $error ) { 1435 return; 1436 } 1437 1438 /* 1439 * If the option API has not been loaded yet, we cannot persist our 1440 * discovery, so there's no point in moving forward. 1441 */ 1442 if ( ! function_exists( 'get_option' ) ) { 1443 return; 1444 } 1445 1446 // For now, we only trigger our safe mode on parse errors. 1447 if ( ! isset( $error['type'] ) || E_PARSE !== $error['type'] ) { 1448 return; 1449 } 1450 1451 try { 1452 wp_record_extension_error( $error ); 1453 1454 // Load custom PHP error template, if present. 1455 if ( is_readable( WP_CONTENT_DIR . '/php-error.php' ) ) { 1456 include WP_CONTENT_DIR . '/php-error.php'; 1457 die(); 1458 } 1459 1460 $message = sprintf( 1461 '<p>%s</p>', 1462 __( 'The site is experiencing technical difficulties.' ) 1463 ); 1464 1465 if ( function_exists( 'get_admin_url' ) ) { 1466 $url = get_admin_url(); 1467 $message .= sprintf( 1468 '<hr><p><em>%s <a href="%s">%s</a></em></p>', 1469 __( 'Are you the site owner?' ), 1470 $url, 1471 __( 'Log into the admin backend to fix this.' ) 1472 ); 1473 } 1474 1475 if ( function_exists( 'apply_filters' ) ) { 1476 /** 1477 * Filters the message that the default PHP error page displays. 1478 * 1479 * @since 5.0.0 1480 * 1481 * @param string $message HTML error message to display. 1482 */ 1483 $message = apply_filters( 'wp_technical_issues_display', $message ); 1484 } 1485 1486 wp_die( $message ); 1487 } catch ( Exception $exception ) { 1488 // Catch exceptions and remain silent. 1489 } 1490 } 1491 1492 /** 1493 * Registers the WordPress premature shutdown handler. 1494 * 1495 * @since 5.0.0 1496 * 1497 * @return void 1498 */ 1499 function wp_register_premature_shutdown_handler() { 1500 register_shutdown_function( 'wp_shutdown_handler_wrapper' ); 1501 } -
src/wp-settings.php
diff --git src/wp-settings.php src/wp-settings.php index eb632238f0..c633f05b1d 100644
require( ABSPATH . WPINC . '/load.php' ); 20 20 require( ABSPATH . WPINC . '/default-constants.php' ); 21 21 require_once( ABSPATH . WPINC . '/plugin.php' ); 22 22 23 // Make sure we register the premature shutdown handler as soon as possible. 24 wp_register_premature_shutdown_handler(); 25 23 26 /* 24 27 * These can't be directly globalized in version.php. When updating, 25 28 * we're including version.php from another installation and don't want … … global $blog_id; 40 43 // Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, SCRIPT_DEBUG, WP_CONTENT_DIR and WP_CACHE. 41 44 wp_initial_constants(); 42 45 46 /* 47 * Allow an optional shutdown handler to be included through a pluggable file. 48 * This file should register a function `wp_handle_shutdown( $context )` that 49 * returns a boolean value. If the return value evaluates to false, the default 50 * shutdown handler will not be executed. 51 */ 52 if ( is_readable( WP_CONTENT_DIR . '/shutdown-handler.php' ) ) { 53 include WP_CONTENT_DIR . '/shutdown-handler.php'; 54 } 55 43 56 // Check for the required PHP version and for the MySQL extension or a database drop-in. 44 57 wp_check_php_mysql_versions(); 45 58 … … if ( is_multisite() ) { 482 495 * @since 3.0.0 483 496 */ 484 497 do_action( 'wp_loaded' ); 498 499 /* 500 * Store the fact that we could successfully execute the entire WordPress 501 * lifecycle. This is used to skip the premature shutdown handler, as it cannot 502 * be unregistered. 503 */ 504 if ( ! defined( 'WP_EXECUTION_SUCCEEDED' ) ) { 505 define( 'WP_EXECUTION_SUCCEEDED', true ); 506 }