Skip to content

Commit

Permalink
Clarified error message for non-writable options table. (#17767)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sergeymitr authored Nov 12, 2020
1 parent 69d2e55 commit 2077bf2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/connection/src/class-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ||
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 2077bf2

Please sign in to comment.