From b60ccbdb266567a20d54357095ee0374b68169f9 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 7 Feb 2023 13:26:46 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@55258 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ajax-actions.php | 5 ++++- src/wp-admin/includes/class-wp-upgrader.php | 4 +++- src/wp-admin/includes/file.php | 4 +++- src/wp-admin/includes/update-core.php | 4 +++- src/wp-includes/comment.php | 5 ++++- src/wp-includes/deprecated.php | 4 +++- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index a4e4e810df..9b03c403e2 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -3528,7 +3528,10 @@ function wp_ajax_get_revision_diffs() { } $return = array(); - set_time_limit( 0 ); + + 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 diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index 1b2df949cf..f6653af742 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -471,7 +471,9 @@ class WP_Upgrader { $destination = $args['destination']; $clear_destination = $args['clear_destination']; - set_time_limit( 300 ); + 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'] ); diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index cc0c0a8af2..e3c1849cc9 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -540,7 +540,9 @@ function wp_edit_theme_plugin_file( $args ) { } // Make sure PHP process doesn't die before loopback requests complete. - set_time_limit( 5 * MINUTE_IN_SECONDS ); + 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. diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 005d70cbf6..ac305ada4a 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -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; - set_time_limit( 300 ); + if ( function_exists( 'set_time_limit' ) ) { + set_time_limit( 300 ); + } /* * Merge the old Requests files and directories into the `$_old_files`. diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 53c6b5df2d..e3d869e9f6 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -3111,7 +3111,10 @@ function pingback( $content, $post ) { $pingback_server_url = discover_pingback_server_uri( $pagelinkedto ); if ( $pingback_server_url ) { - set_time_limit( 60 ); + if ( function_exists( 'set_time_limit' ) ) { + set_time_limit( 60 ); + } + // Now, the RPC call. $pagelinkedfrom = get_permalink( $post ); diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php index 3787d71297..280083114c 100644 --- a/src/wp-includes/deprecated.php +++ b/src/wp-includes/deprecated.php @@ -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' ); - @set_time_limit( 60 ); + if ( function_exists( 'set_time_limit' ) ) { + @set_time_limit( 60 ); + } if ( $red > 5 ) return false;