From 2077bf2c3baf0cd1a8ea9f8f14e878d80de9e0a6 Mon Sep 17 00:00:00 2001 From: Sergey Mitroshin Date: Thu, 12 Nov 2020 17:28:28 -0600 Subject: [PATCH] Clarified error message for non-writable options table. (#17767) When the wp_options table is not writeable, connecting Jetpack will result in the error Verification secrets not found. This PR clarifies the error, informing the user that they need to confirm the options table is writable. --- packages/connection/src/class-manager.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; } /**