From 0c34b6e4341bc880a2d1ca4b32810c5e766cd3eb Mon Sep 17 00:00:00 2001 From: Malith Senaweera Date: Mon, 15 May 2023 07:48:05 -0700 Subject: [PATCH 1/4] Bring back the rest-user-exists-controller This fixes an error that happens during the plugin upgrade process. We'll need to keep this file until a more robust solution is found. --- .../class-wc-rest-user-exists-controller.php | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 includes/admin/class-wc-rest-user-exists-controller.php diff --git a/includes/admin/class-wc-rest-user-exists-controller.php b/includes/admin/class-wc-rest-user-exists-controller.php new file mode 100644 index 00000000000..920b1f09459 --- /dev/null +++ b/includes/admin/class-wc-rest-user-exists-controller.php @@ -0,0 +1,78 @@ +namespace, + '/' . $this->rest_base, + [ + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => [ $this, 'user_exists' ], + 'permission_callback' => '__return_true', + 'args' => [ + 'email' => [ + 'required' => true, + 'description' => __( 'Email address.', 'woocommerce-payments' ), + 'type' => 'string', + 'format' => 'email', + ], + ], + ] + ); + } + + /** + * Retrieve if a user exists by email address. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return WP_REST_Response + */ + public function user_exists( WP_REST_Request $request ): WP_REST_Response { + $email = $request->get_param( 'email' ); + $email_exists = ! empty( email_exists( $email ) ); + $message = null; + + if ( $email_exists ) { + // Use this function to show the core error message. + $error = wc_create_new_customer( $email ); + $message = $error->get_error_message(); + } + + return new WP_REST_Response( + [ + 'user-exists' => $email_exists, + 'message' => $message, + ] + ); + } +} + From c0d5e695c3cf375958d9c921a44cd0e4b1565b50 Mon Sep 17 00:00:00 2001 From: Malith Senaweera Date: Mon, 15 May 2023 07:59:17 -0700 Subject: [PATCH 2/4] Add changelog entry --- changelog/fix-plugin-upgrade | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/fix-plugin-upgrade diff --git a/changelog/fix-plugin-upgrade b/changelog/fix-plugin-upgrade new file mode 100644 index 00000000000..ca961eca64b --- /dev/null +++ b/changelog/fix-plugin-upgrade @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Missing file during plugin upgrade From 1dd9f4056873ebe1973542c8da093807686740da Mon Sep 17 00:00:00 2001 From: Malith Senaweera Date: Mon, 15 May 2023 08:17:29 -0700 Subject: [PATCH 3/4] Remove changelog --- changelog/fix-plugin-upgrade | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 changelog/fix-plugin-upgrade diff --git a/changelog/fix-plugin-upgrade b/changelog/fix-plugin-upgrade deleted file mode 100644 index ca961eca64b..00000000000 --- a/changelog/fix-plugin-upgrade +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Missing file during plugin upgrade From e039b80f89f38c203947705521ed54f0af51f939 Mon Sep 17 00:00:00 2001 From: Malith Senaweera Date: Mon, 15 May 2023 09:01:39 -0700 Subject: [PATCH 4/4] Add back changelog --- changelog/fix-plugin-upgrade | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/fix-plugin-upgrade diff --git a/changelog/fix-plugin-upgrade b/changelog/fix-plugin-upgrade new file mode 100644 index 00000000000..4f4b515c90b --- /dev/null +++ b/changelog/fix-plugin-upgrade @@ -0,0 +1,5 @@ +Significance: patch +Type: fix +Comment: Temporary fix to hide an error notice that's printed during the plugin upgrade + +