Skip to content
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

Fix install and DB update errors #467

Merged
merged 3 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 6 additions & 37 deletions lib/WP_Auth0_DBManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function init() {
}

public function check_update() {
if ( $this->current_db_version !== AUTH0_DB_VERSION ) {
if ( $this->current_db_version && $this->current_db_version !== AUTH0_DB_VERSION ) {
$this->install_db();
}
}
Expand All @@ -43,13 +43,6 @@ public function install_db( $version_to_install = null, $app_token = '' ) {
$client_secret = $options->get( 'client_secret' );
$domain = $options->get( 'domain' );
$sso = $options->get( 'sso' );

if ($this->current_db_version === 0) {
$options->set('auth0_table', false);
} elseif($options->get('auth0_table') === null) {
$options->set('auth0_table', true);
}

$cdn_url = $options->get( 'cdn_url' );

if ( $this->current_db_version <= 7 ) {
Expand All @@ -75,17 +68,6 @@ public function install_db( $version_to_install = null, $app_token = '' ) {
}

if ( $this->current_db_version < 10 ) {

if ($options->get('use_lock_10') === null) {

if ( strpos( $cdn_url, '10.' ) === false ) {
$options->set('use_lock_10', false);
} else {
$options->set('use_lock_10', true);
}

}

$dict = $options->get('dict');

if (!empty($dict))
Expand All @@ -104,16 +86,6 @@ public function install_db( $version_to_install = null, $app_token = '' ) {

}

if ( $this->current_db_version < 12 ) {

if ( strpos( $cdn_url, '10.' ) === false ) {
$options->set('use_lock_10', false);
} else {
$options->set('use_lock_10', true);
}

}

if ( $this->current_db_version < 13 ) {
$ips = $options->get('migration_ips');
$oldips = '138.91.154.99,54.221.228.15,54.183.64.135,54.67.77.38,54.67.15.170,54.183.204.205,54.173.21.107,54.85.173.28';
Expand All @@ -136,10 +108,8 @@ public function install_db( $version_to_install = null, $app_token = '' ) {
// 3.4.0

if ( $this->current_db_version < 15 || 15 === $version_to_install ) {

$options->set('use_lock_10', true);
$options->set('cdn_url', '//cdn.auth0.com/js/lock/11.1/lock.min.js');
$options->set('auth0js-cdn', '//cdn.auth0.com/js/auth0/9.1/auth0.min.js');
$options->set('cdn_url', WPA0_LOCK_CDN_URL);
$options->set('auth0js-cdn', WPA0_AUTH0_JS_CDN_URL);
$options->set('cache_expiration', 1440);

// Update Client
Expand Down Expand Up @@ -180,11 +150,11 @@ public function install_db( $version_to_install = null, $app_token = '' ) {
// Update Lock and Auth versions

if ( '//cdn.auth0.com/js/lock/11.0.0/lock.min.js' === $options->get( 'cdn_url' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this hardcoded to 11.0.0 and later a different value is assigned? same for the one below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is difficult to follow, I know, but they are, technically, doing different things.

$options->set( 'cdn_url', '//cdn.auth0.com/js/lock/11.1/lock.min.js' );
$options->set( 'cdn_url', WPA0_LOCK_CDN_URL );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already set under this next line (snippet)

if ( $this->current_db_version < 15 || 15 === $version_to_install  ) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly. Logic is difficult to follow but this serves a different function.

}

if ( '//cdn.auth0.com/js/auth0/9.0.0/auth0.min.js' === $options->get( 'auth0js-cdn' ) ) {
$options->set( 'auth0js-cdn', '//cdn.auth0.com/js/auth0/9.1/auth0.min.js' );
$options->set( 'auth0js-cdn', WPA0_AUTH0_JS_CDN_URL );
}

// Update app type and client grant
Expand Down Expand Up @@ -218,13 +188,12 @@ public function install_db( $version_to_install = null, $app_token = '' ) {
delete_option( 'wp_auth0_client_grant_failed' );
update_option( 'wp_auth0_client_grant_success', 1 );

if ( 409 !== $client_grant_created[ 'statusCode' ] ) {
if ( 409 !== $client_grant_created->statusCode ) {
WP_Auth0_ErrorManager::insert_auth0_error(
__METHOD__,
'Client Grant has been successfully created!'
);
}

} else {
WP_Auth0_ErrorManager::insert_auth0_error( __METHOD__, sprintf(
__( 'Unable to automatically create Client Grant. Please go to your Auth0 Dashboard '
Expand Down
1 change: 0 additions & 1 deletion lib/WP_Auth0_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ protected function defaults() {
'version' => 1,
'last_step' => 1,
'migration_token_id' => null,
'use_lock_10' => true,
'jwt_auth_integration' => false,
'amplificator_title' => '',
'amplificator_subtitle' => '',
Expand Down