General: Check that `set_time_limit()` function is available before using it in core.

This avoids a fatal error if the function is disabled on certain environments.

Props theode, jokerrs, johnbillion, hellofromTonya, costdev, jrf, azaozz, SergeyBiryukov.
Fixes #55711.
Built from https://develop.svn.wordpress.org/trunk@55258


git-svn-id: http://core.svn.wordpress.org/trunk@54791 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-02-07 13:28:18 +00:00
parent 804fbe781a
commit b29536b060
7 changed files with 21 additions and 7 deletions

View File

@ -3528,7 +3528,10 @@ function wp_ajax_get_revision_diffs() {
}
$return = array();
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 0 );
}
foreach ( $_REQUEST['compare'] as $compare_key ) {
list( $compare_from, $compare_to ) = explode( ':', $compare_key ); // from:to

View File

@ -471,7 +471,9 @@ class WP_Upgrader {
$destination = $args['destination'];
$clear_destination = $args['clear_destination'];
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 300 );
}
if ( empty( $source ) || empty( $destination ) ) {
return new WP_Error( 'bad_request', $this->strings['bad_request'] );

View File

@ -540,7 +540,9 @@ function wp_edit_theme_plugin_file( $args ) {
}
// Make sure PHP process doesn't die before loopback requests complete.
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 5 * MINUTE_IN_SECONDS );
}
// Time to wait for loopback requests to finish.
$timeout = 100; // 100 seconds.

View File

@ -1053,7 +1053,9 @@ $_new_bundled_files = array(
function update_core( $from, $to ) {
global $wp_filesystem, $_old_files, $_old_requests_files, $_new_bundled_files, $wpdb;
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 300 );
}
/*
* Merge the old Requests files and directories into the `$_old_files`.

View File

@ -3111,7 +3111,10 @@ function pingback( $content, $post ) {
$pingback_server_url = discover_pingback_server_uri( $pagelinkedto );
if ( $pingback_server_url ) {
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 60 );
}
// Now, the RPC call.
$pagelinkedfrom = get_permalink( $post );

View File

@ -3659,7 +3659,9 @@ function post_permalink( $post = 0 ) {
function wp_get_http( $url, $file_path = false, $red = 1 ) {
_deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' );
if ( function_exists( 'set_time_limit' ) ) {
@set_time_limit( 60 );
}
if ( $red > 5 )
return false;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-55257';
$wp_version = '6.2-alpha-55258';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.