From 8d2ee69f9d12edfb11bf6bc8032aaf26e361a0cf Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 8 Jan 2019 06:07:51 +0000 Subject: [PATCH] Users: Use `email_exists()` in `send_confirmation_on_profile_email()`, instead of a manual query. This gives us caching, and removes the use of the `$wpdb` global. Props spacedmonkey, pento. Fixes #45748. Built from https://develop.svn.wordpress.org/trunk@44465 git-svn-id: http://core.svn.wordpress.org/trunk@44296 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/user.php | 5 ++--- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index 09be161e15..d99885142d 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -2692,10 +2692,9 @@ function _wp_get_current_user() { * @since 4.9.0 This function was moved from wp-admin/includes/ms.php so it's no longer Multisite specific. * * @global WP_Error $errors WP_Error object. - * @global wpdb $wpdb WordPress database object. */ function send_confirmation_on_profile_email() { - global $errors, $wpdb; + global $errors; $current_user = wp_get_current_user(); if ( ! is_object( $errors ) ) { @@ -2719,7 +2718,7 @@ function send_confirmation_on_profile_email() { return; } - if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) { + if ( email_exists( $_POST['email'] ) ) { $errors->add( 'user_email', __( 'ERROR: The email address is already used.' ), diff --git a/wp-includes/version.php b/wp-includes/version.php index 99fa814bee..f265d0bd6f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.1-alpha-44464'; +$wp_version = '5.1-alpha-44465'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.