From 8a8bd9192b9a9b7b998048049139aad70140d723 Mon Sep 17 00:00:00 2001 From: davidbaumwald Date: Fri, 7 Oct 2022 14:25:14 +0000 Subject: [PATCH] Administration: Guard against undefined `$GLOBALS['hook_suffix']` in `WP_Screen::get()`. When initially defaulting the screen `$id` in `WP_Screen::get()`, if the `$hook_name` parameter is not supplied, an `else` fallback uses `$GLOBALS['hook_suffix']`. However, in some cases, `hook_suffix` doesn't exist in the global scope. This produces an "Undefined index" notice on < PHP 8, and a warning in >= PHP 8. This change ensures `$GLOBALS['hook_suffix']` has a value before using it as a fallback for the screen ID. Props splendorstudio, SergeyBiryukov, htdat, mukesh27, dd32, costdev. Fixes #49089. Built from https://develop.svn.wordpress.org/trunk@54414 git-svn-id: http://core.svn.wordpress.org/trunk@53973 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-screen.php | 3 ++- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/class-wp-screen.php b/wp-admin/includes/class-wp-screen.php index 7b7290011c..61217462eb 100644 --- a/wp-admin/includes/class-wp-screen.php +++ b/wp-admin/includes/class-wp-screen.php @@ -212,6 +212,7 @@ final class WP_Screen { return $hook_name; } + $id = ''; $post_type = null; $taxonomy = null; $in_admin = false; @@ -220,7 +221,7 @@ final class WP_Screen { if ( $hook_name ) { $id = $hook_name; - } else { + } elseif ( ! empty( $GLOBALS['hook_suffix'] ) ) { $id = $GLOBALS['hook_suffix']; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 619d82f6ac..f46a6ffb02 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-beta3-54413'; +$wp_version = '6.1-beta3-54414'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.