#56336 closed defect (bug) (fixed)
Fatal Error/Warning when invalid `sitemap` query var presented.
Reported by: | dd32 | Owned by: | peterwilsoncc |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Sitemaps | Keywords: | php8 has-patch has-unit-tests |
Focuses: | Cc: |
Description
A request such as https://example.org/?sitemap[foo]=bar will result in a fatal error being generated under PHP8, and a warning under PHP7.
PHP 7.4: E_WARNING: Illegal offset type in isset or empty in wp-includes/sitemaps/class-wp-sitemaps-registry.php:68 PHP8.1: Fatal error: Uncaught Error: Illegal offset type in isset or empty in wp-includes/sitemaps/class-wp-sitemaps-registry.php on line 68 Call stack: WP_Sitemaps_Registry::get_provider() wp-includes/sitemaps.php:114 get_sitemap_url() wp-includes/canonical.php:428 redirect_canonical() wp-includes/class-wp-hook.php:307 ...
This is partially related to #17737
Attachments (1)
Change History (9)
#2
@
2 years ago
- Keywords reporter-feedback removed
I'm getting the warning for illegal offset type when appending ?sitemap[foo]=bar
, but in my case it's wp-includes/taxonomy.php
:
Warning: Illegal offset type in isset or empty in src/wp-includes/taxonomy.php on line 340
Looks like both may need an is_string()
check on the value being passed to isset()
. Both are documented as a string
.
#3
@
2 years ago
Thanks @costdev!
Adding the type check to WP_Sitemaps_Registry::get_provider()
appears to work for me, the taxonomy_exists()
change didn't seem to be required in my environment but I can't see any harm in it or reason not to include it in the same change.
This ticket was mentioned in PR #3065 on WordPress/wordpress-develop by costdev.
2 years ago
#4
- Keywords has-patch has-unit-tests added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/56336
#5
@
2 years ago
- Owner set to peterwilsoncc
- Resolution set to fixed
- Status changed from new to closed
In 53838:
peterwilsoncc commented on PR #3065:
2 years ago
#6
Merged https://core.trac.wordpress.org/changeset/53838 / b96a51c529
A quick attempt to reproduce this by appending
?sitemap[foo]=bar
to the home url on a local (alpha, PHP 7.2) and remote (6.0.1, PHP 7.4) site failed to produce a warning/error.Are there any other settings/steps required to produce this?
Edit: Nevermind, got it. Hadn't realised the sitemap plugin was deactivated.