From 4a1d65a3dbfb34ca387f962b65f083d82f3b7689 Mon Sep 17 00:00:00 2001 From: Josh Cunningham Date: Fri, 5 Oct 2018 08:09:22 -0700 Subject: [PATCH 1/3] Deprecate unused WP_Auth0_LoginManager methods and props --- lib/WP_Auth0_LoginManager.php | 56 +++++++++++++++++++++---------- lib/WP_Auth0_Settings_Section.php | 5 +-- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/lib/WP_Auth0_LoginManager.php b/lib/WP_Auth0_LoginManager.php index cfc0bb99..8d288a9a 100755 --- a/lib/WP_Auth0_LoginManager.php +++ b/lib/WP_Auth0_LoginManager.php @@ -24,7 +24,7 @@ class WP_Auth0_LoginManager { /** * Should the new user have an administrator role? * - * TODO: Deprecate, not used + * @deprecated - 3.8.0 * * @var bool|null */ @@ -33,7 +33,7 @@ class WP_Auth0_LoginManager { /** * Ignore verified email requirement in Settings > Advanced. * - * TODO: Deprecate, not used + * @deprecated - 3.8.0 * * @var bool */ @@ -51,8 +51,8 @@ class WP_Auth0_LoginManager { * * @param WP_Auth0_UsersRepo $users_repo - see member variable doc comment. * @param WP_Auth0_Options|null $a0_options - see member variable doc comment. - * @param null|bool $admin_role - see member variable doc comment. - * @param bool $ignore_unverified_email - see member variable doc comment. + * @param null|bool $admin_role - @deprecated - 3.8.0. + * @param bool $ignore_unverified_email - @deprecated - 3.8.0. */ public function __construct( WP_Auth0_UsersRepo $users_repo, @@ -60,15 +60,24 @@ public function __construct( $admin_role = null, $ignore_unverified_email = false ) { - $this->admin_role = $admin_role; - $this->ignore_unverified_email = $ignore_unverified_email; - $this->users_repo = $users_repo; + $this->users_repo = $users_repo; if ( $a0_options instanceof WP_Auth0_Options ) { $this->a0_options = $a0_options; } else { $this->a0_options = WP_Auth0_Options::Instance(); } + + $this->admin_role = $admin_role; + $this->ignore_unverified_email = $ignore_unverified_email; + + if ( func_num_args() > 2 ) { + // phpcs:ignore + trigger_error( + sprintf( __( '$admin_role and $ignore_unverified_email are deprecated.', 'wp-auth0' ), __METHOD__ ), + E_USER_DEPRECATED + ); + } } /** @@ -625,17 +634,6 @@ public function auth0_singlelogout_footer() { } } - /** - * End the PHP session. - * - * TODO: Deprecate - */ - public function end_session() { - if ( session_id() ) { - session_destroy(); - } - } - /** * Get and filter the scope used for access and ID tokens. * @@ -774,6 +772,28 @@ protected function die_on_login( $msg = '', $code = 0, $login_link = true ) { ); } + /* + * + * DEPRECATED + * + */ + + /** + * End the PHP session. + * + * @deprecated - 3.8.0, not used and no replacement provided. + * + * @codeCoverageIgnore - Deprecated + */ + public function end_session() { + // phpcs:ignore + trigger_error( sprintf( __( 'Method %s is deprecated.', 'wp-auth0' ), __METHOD__ ), E_USER_DEPRECATED ); + + if ( session_id() ) { + session_destroy(); + } + } + /** * Login using oauth/ro endpoint * diff --git a/lib/WP_Auth0_Settings_Section.php b/lib/WP_Auth0_Settings_Section.php index c1966019..a4e2ea63 100644 --- a/lib/WP_Auth0_Settings_Section.php +++ b/lib/WP_Auth0_Settings_Section.php @@ -65,8 +65,5 @@ public function init_menu() { } } - // TODO: deprecate - public function redirect_to_help() { - - } + public function redirect_to_help() {} } From 69e1f7c9775efff9d4bdfcc88186d59a04e481ff Mon Sep 17 00:00:00 2001 From: Josh Cunningham Date: Fri, 5 Oct 2018 08:18:23 -0700 Subject: [PATCH 2/3] Deprecate parameters in the login flow --- lib/WP_Auth0_Users.php | 11 +++++++++++ lib/WP_Auth0_UsersRepo.php | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/WP_Auth0_Users.php b/lib/WP_Auth0_Users.php index 7db6fcb4..3ea8e298 100644 --- a/lib/WP_Auth0_Users.php +++ b/lib/WP_Auth0_Users.php @@ -1,5 +1,14 @@ email ) ) { @@ -76,6 +85,8 @@ public static function create_user( $userinfo, $role = null ) { ); if ( $role ) { + // phpcs:ignore + trigger_error( sprintf( __( '$role parameter is deprecated.', 'wp-auth0' ), __METHOD__ ), E_USER_DEPRECATED ); $user_data['role'] = 'administrator'; } diff --git a/lib/WP_Auth0_UsersRepo.php b/lib/WP_Auth0_UsersRepo.php index 4f914ec5..fa38d3c9 100644 --- a/lib/WP_Auth0_UsersRepo.php +++ b/lib/WP_Auth0_UsersRepo.php @@ -73,9 +73,9 @@ public function tokenHasRequiredScopes( $jwt ) { * * @param object $userinfo - Profile object from Auth0. * @param string $token - ID token from Auth0. - * @param null|string $access_token - TODO: Deprecate, not used - * @param null|string $role - TODO: Deprecate, not used - * @param bool $skip_email_verified - TODO: Deprecate, not used + * @param null|string $access_token - @deprecated - 3.8.0. + * @param null|string $role - @deprecated - 3.8.0. + * @param bool $skip_email_verified - @deprecated - 3.8.0. * * @return int|null|WP_Error * @@ -84,6 +84,18 @@ public function tokenHasRequiredScopes( $jwt ) { * @throws WP_Auth0_RegistrationNotEnabledException */ public function create( $userinfo, $token, $access_token = null, $role = null, $skip_email_verified = false ) { + + if ( func_num_args() > 2 ) { + // phpcs:ignore + trigger_error( + sprintf( + __( '$access_token, $role, and $skip_email_verified params are deprecated.', 'wp-auth0' ), + __METHOD__ + ), + E_USER_DEPRECATED + ); + } + $auth0_sub = $userinfo->sub; list($strategy) = explode( '|', $auth0_sub ); $opts = WP_Auth0_Options::Instance(); From 192557a547664416cc0016278089cc22cd5a49a6 Mon Sep 17 00:00:00 2001 From: Josh Cunningham Date: Fri, 5 Oct 2018 08:33:03 -0700 Subject: [PATCH 3/3] PR feedback --- lib/WP_Auth0_Users.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WP_Auth0_Users.php b/lib/WP_Auth0_Users.php index 3ea8e298..7cb3edb8 100644 --- a/lib/WP_Auth0_Users.php +++ b/lib/WP_Auth0_Users.php @@ -5,7 +5,7 @@ class WP_Auth0_Users { * Create a WordPress user with Auth0 data. * * @param object $userinfo - User profile data from Auth0. - * @param null|boolean $role - Set the sole as administrator - @deprecated - 3.8.0. + * @param null|boolean $role - Set the role as administrator - @deprecated - 3.8.0. * * @return int|WP_Error */