Make WordPress Core

Opened 16 months ago

Closed 8 weeks ago

#62562 closed enhancement (fixed)

Ensure get_current_screen() returns WP_Screen|null

Reported by: marian1's profile marian1 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 7.0 Priority: normal
Severity: trivial Version:
Component: Administration Keywords: has-patch dev-feedback
Focuses: Cc:

Description

Currently, get_current_screen() simply checks whether the global variable $current_screen is set before returning it. Since global variables may be overridden, it should confirm that $current_screen is actually a WP_Screen object to ensure that get_current_screen() reliably returns a valid WP_Screen object.

Change History (6)

This ticket was mentioned in PR #7885 on WordPress/wordpress-develop by @marian1.


16 months ago
#1

  • Keywords has-patch added; needs-patch removed

#2 @mayanktripathi32
16 months ago

  • Keywords dev-feedback needs-testing added

#3 @abcd95
16 months ago

  • Keywords needs-testing removed

Test Report

Description

This report validates that the indicated patch works as expected.

Environment

  • WordPress: 6.8-alpha-59274-src
  • PHP: 8.2.25
  • Server: nginx/1.27.2
  • Database: mysqli (Server: 8.0.40 / Client: mysqlnd 8.2.25)
  • Browser: Chrome 131.0.0.0
  • OS: macOS

Actual Results

✅ Issue addressed by the patch.

#4 @im3dabasia1
16 months ago

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/7885.diff

Environment

  • WordPress: 6.8-alpha-59274-src
  • PHP: 8.2.25
  • Server: nginx/1.27.2
  • Database: mysqli (Server: 8.0.40 / Client: mysqlnd 8.2.25)
  • Browser: Chrome 129.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.0
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch.

#5 @SergeyBiryukov
8 weeks ago

  • Milestone changed from Awaiting Review to 7.0

#6 @SergeyBiryukov
8 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 61484:

Administration: Ensure get_current_screen() returns WP_Screen or null.

This adds a check that the $current_screen global is not only defined, but also has the correct type.

Follow-up to [15746].

Props marian1, mayanktripathi32, abcd95, im3dabasia1, SergeyBiryukov.
Fixes #62562.

Note: See TracTickets for help on using tickets.