Commit 7b2e78ee96 for wordpress.org
commit 7b2e78ee962d82c479ff6cd72a940483ed363253
Author: lancewillett <lancewillett@git.wordpress.org>
Date: Mon Nov 2 16:10:54 2026 +0000
Code Quality: Declare existing admin globals and simplify variable checks.
Document existing globals in user and plugin administration screens, initialize the remaining redirect and privacy management URL defaults, and remove a redundant old-user-data check from `wp_insert_user()`.
Remove the corresponding PHPStan baseline entries.
Developed in: https://github.com/WordPress/wordpress-develop/pull/11979
Props huzaifaalmesbah, noruzzaman.
See #65817.
Built from https://develop.svn.wordpress.org/trunk@65195
git-svn-id: http://core.svn.wordpress.org/trunk@64344 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php
index 520bd03dee..62e904acca 100644
--- a/wp-admin/plugins.php
+++ b/wp-admin/plugins.php
@@ -9,6 +9,14 @@
/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';
+/**
+ * @global string $status Current plugin status view, set by WP_Plugins_List_Table.
+ * @global int $page Current page number, set by WP_Plugins_List_Table.
+ * @global array $plugins Set by WP_Plugins_List_Table::prepare_items().
+ * @global int $user_ID ID of the current user, set during authentication.
+ */
+global $status, $page, $plugins, $user_ID;
+
if ( ! current_user_can( 'activate_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to manage plugins for this site.' ) );
}
diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php
index df72f7250b..d1f99690b8 100644
--- a/wp-admin/user-edit.php
+++ b/wp-admin/user-edit.php
@@ -12,6 +12,13 @@ require_once __DIR__ . '/admin.php';
/** WordPress Translation Installation API */
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
+/**
+ * @global wpdb $wpdb WordPress database abstraction object.
+ * @global array $_wp_admin_css_colors Registered admin color schemes.
+ * @global WP_Roles $wp_roles The roles object.
+ */
+global $wpdb, $_wp_admin_css_colors, $wp_roles;
+
$action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
$user_id = ! empty( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0;
$wp_http_referer = ! empty( $_REQUEST['wp_http_referer'] ) ? sanitize_url( $_REQUEST['wp_http_referer'] ) : '';
diff --git a/wp-admin/user-new.php b/wp-admin/user-new.php
index 73d74aa6db..920fa4b768 100644
--- a/wp-admin/user-new.php
+++ b/wp-admin/user-new.php
@@ -9,6 +9,12 @@
/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';
+/**
+ * @global wpdb $wpdb WordPress database abstraction object.
+ * @global int $blog_id The current site (blog) ID on multisite.
+ */
+global $wpdb, $blog_id;
+
if ( is_multisite() ) {
if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) {
wp_die(
@@ -240,11 +246,6 @@ Please click the following link to confirm the invite:
);
if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
- /**
- * @global wpdb $wpdb WordPress database abstraction object.
- */
- global $wpdb;
-
$key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
$new_user = wpmu_activate_signup( $key );
if ( is_wp_error( $new_user ) ) {
diff --git a/wp-admin/users.php b/wp-admin/users.php
index 0af7a33c77..3668922156 100644
--- a/wp-admin/users.php
+++ b/wp-admin/users.php
@@ -10,6 +10,15 @@
/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';
+/**
+ * @global WP_User $current_user The current user, set during authentication.
+ * @global WP_Roles $wp_roles The roles object.
+ * @global wpdb $wpdb WordPress database abstraction object.
+ * @global string $usersearch User search query, set by WP_Users_List_Table.
+ * @global int $blog_id The current site (blog) ID on multisite.
+ */
+global $current_user, $wp_roles, $wpdb, $usersearch, $blog_id;
+
if ( ! current_user_can( 'list_users' ) ) {
wp_die(
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
@@ -93,7 +102,8 @@ get_current_screen()->set_screen_reader_content(
);
if ( empty( $_REQUEST ) ) {
- $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
+ $redirect = '';
+ $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
} elseif ( isset( $_REQUEST['wp_http_referer'] ) ) {
$redirect = remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), wp_unslash( $_REQUEST['wp_http_referer'] ) );
$referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( $redirect ) . '" />';
diff --git a/wp-includes/user.php b/wp-includes/user.php
index 915020f21e..02a412b291 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -2428,7 +2428,7 @@ function wp_insert_user( $userdata ) {
* check if current email and new email are the same, and check `email_exists`
* accordingly.
*/
- if ( ( ! $update || ( ! empty( $old_user_data ) && 0 !== strcasecmp( $user_email, $old_user_data->user_email ) ) )
+ if ( ( ! $update || 0 !== strcasecmp( $user_email, $old_user_data->user_email ) )
&& ! defined( 'WP_IMPORTING' )
&& email_exists( $user_email )
) {
@@ -4326,6 +4326,7 @@ function _wp_privacy_send_request_confirmation_notification( $request_id ) {
return;
}
+ $manage_url = '';
if ( 'export_personal_data' === $request->action_name ) {
$manage_url = admin_url( 'export-personal-data.php' );
} elseif ( 'remove_personal_data' === $request->action_name ) {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 43e0e98b6b..88223c9c87 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta3-65194';
+$wp_version = '7.2-beta3-65195';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.