#55222 closed defect (bug) (fixed)
PHP Warning when using 'do_parse_request' filter with '__return_false'
Reported by: | dd32 | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | minor | Version: | |
Component: | Query | Keywords: | has-patch |
Focuses: | Cc: |
Description
When disabling request parsing via the do_parse_request
filter, if you're simply disabling the parsing entirely instead of replacing, you end up with a PHP Warning:
E_WARNING: array_keys() expects parameter 1 to be array, null given in wp-includes/class-wp.php:548
This can be reproduced by this:
add_filter( 'do_parse_request', '__return_false' );
Upon looking at the WP
class, it appears that the query_vars
property isn't initialised to an array()
until after the above filter is called, but is then expected to be set to an array in the following function calls.
It seems safe to me to simply pre-set this to an empty array, and the other class properties while we're at it.
Example workaround: https://meta.trac.wordpress.org/changeset/11592
See PR.
Change History (6)
This ticket was mentioned in PR #2341 on WordPress/wordpress-develop by dd32.
3 years ago
#1
- Keywords has-patch added
SergeyBiryukov commented on PR #2341:
3 years ago
#3
Thanks for the PR! Looks like the tests did not pass previously because the isset( $this->matched_rule )
condition in WP::parse_request()
needed an update to ! empty( $this->matched_rule )
, since it's always set now. With this change, the tests are passing, so this seems ready for commit.
#4
@
3 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 52804:
Trac ticket: https://core.trac.wordpress.org/ticket/55222