Opened 4 years ago
Closed 7 weeks ago
#56607 closed defect (bug) (fixed)
Improve doc for WP_Screen class
| Reported by: | Chouby | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.1 |
| Component: | Administration | Version: | 3.3 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | docs |
Description
WooCommerce 6.9 introduced a conflict with several plugins by accessing to the property WP_Screen::id and expecting it to be a string, while conflicting plugins just set the current screen with a simple call to set_current_screen() without parameter. In this case, get_current_screen() returns a WP_Screen object with the property id set to null.
This pushed me to review the doc of the class and notice that several properties are not correctly documented for this case.
Attachments (1)
Change History (5)
This ticket was mentioned in PR #12653 on WordPress/wordpress-develop by @arkaprabhachowdhury.
7 weeks ago
#2
## Summary
- Correct the documented type of
WP_Screen::$_screen_settings. - Account for the property being
nulluntilshow_screen_options()initializes it.
The ticket's other proposed type changes have already been addressed by later commits or are no longer applicable to current trunk.
## Testing
php -l src/wp-admin/includes/class-wp-screen.phpphpcbf --standard=phpcs.xml.dist src/wp-admin/includes/class-wp-screen.phpphpcs --standard=phpcs.xml.dist src/wp-admin/includes/class-wp-screen.php
#3
in reply to: ↑ description
@
7 weeks ago
- Milestone Awaiting Review → 7.1
Replying to Chouby:
...accessing to the property
WP_Screen::idand expecting it to be a string, while conflicting plugins just set the current screen with a simple call toset_current_screen()without parameter. In this case,get_current_screen()returns aWP_Screenobject with the propertyidset to null.
Thanks for the ticket! Just noting that I cannot reproduce this specific issue in current trunk:
require 'wp-load.php'; require 'wp-admin/includes/admin.php'; set_current_screen(); var_dump( get_current_screen() );
Both WP_Screen::$id and WP_Screen::$base are an empty string in this scenario in my testing.
That said, WP_Screen::$_screen_settings is indeed null and appears to be the only property left to correct here, as the other affected properties have already been adjusted in [55693] and [61300].
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Just for reference, the issue opened in WooCommerce: https://github.com/woocommerce/woocommerce/issues/34725