-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to set longer timeouts for Register() in connect #7736
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4776,11 +4776,25 @@ public static function delete_secrets( $action, $user_id ) { | |
* @since 2.6 | ||
* @return int | ||
**/ | ||
public function get_remote_query_timeout_limit() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we find a way to deprecate |
||
public static function get_max_execution_time() { | ||
$timeout = (int) ini_get( 'max_execution_time' ); | ||
if ( ! $timeout ) // Ensure exec time set in php.ini | ||
$timeout = 30; | ||
return intval( $timeout / 2 ); | ||
$timeout = 30; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're touching this code, can we add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, there are leading spaces before all lines except one in this method. That's a minor nitpick, but should be an easy fix if you go back in. |
||
return $timeout; | ||
} | ||
|
||
/** | ||
* Sets a minimum request timeout, and returns the current timeout | ||
* | ||
* @since 5.3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll need to update this to 5.4. |
||
**/ | ||
public static function set_min_time_limit( $min_timeout ) { | ||
$timeout = self::get_max_execution_time(); | ||
if ( $timeout < $min_timeout ) { | ||
$timeout = $min_timeout; | ||
set_time_limit( $timeout ); | ||
} | ||
return $timeout; | ||
} | ||
|
||
|
||
|
@@ -4847,7 +4861,9 @@ public static function register() { | |
return new Jetpack_Error( 'missing_secrets' ); | ||
} | ||
|
||
$timeout = Jetpack::init()->get_remote_query_timeout_limit(); | ||
// better to try (and fail) to set a higher timeout than this system | ||
// supports than to have register fail for more users than it should | ||
$timeout = Jetpack::set_min_time_limit( 60 ) / 2; | ||
|
||
$gmt_offset = get_option( 'gmt_offset' ); | ||
if ( ! $gmt_offset ) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're effectively deleting and creating a new method here, we should probably update the
@since
.