diff --git a/packages/connection/src/class-manager.php b/packages/connection/src/class-manager.php index e433cd46cf6cc..9e62dd06c1144 100644 --- a/packages/connection/src/class-manager.php +++ b/packages/connection/src/class-manager.php @@ -829,6 +829,10 @@ public function register( $api_endpoint = 'register' ) { add_action( 'pre_update_jetpack_option_register', array( '\\Jetpack_Options', 'delete_option' ) ); $secrets = $this->generate_secrets( 'register', get_current_user_id(), 600 ); + if ( false === $secrets ) { + return new WP_Error( 'cannot_save_secrets', __( 'Jetpack experienced an issue trying to save options (cannot_save_secrets). We suggest that you contact your hosting provider, and ask them for help checking that the options table is writable on your site.', 'jetpack' ) ); + } + if ( empty( $secrets['secret_1'] ) || empty( $secrets['secret_2'] ) || @@ -1330,8 +1334,8 @@ public function generate_secrets( $action, $user_id = false, $exp = 600 ) { $secrets[ $secret_name ] = $secret_value; - \Jetpack_Options::update_raw_option( self::SECRETS_OPTION_NAME, $secrets ); - return $secrets[ $secret_name ]; + $res = Jetpack_Options::update_raw_option( self::SECRETS_OPTION_NAME, $secrets ); + return $res ? $secrets[ $secret_name ] : false; } /**