Opened 5 weeks ago
Closed 3 weeks ago
#62334 closed defect (bug) (duplicate)
Undefined array key "host" in canonical.php
Reported by: | morebrackets | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Canonical | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Nginx version: nginx/1.26.2
PHP version: PHP 8.3.6 (cli) (built: Sep 30 2024 15:17:17) (NTS)
Note: Nginx now supports HTTP/3 (QUIK) which may not report the host & scheme vars the same way as HTTP/1 & HTTP/2
==> /var/log/nginx/error.log <== 2024/11/02 04:51:32 [error] 52855#52855: *11 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "host" in /.../wp-includes/canonical.php on line 716; PHP message: PHP Warning: Undefined array key "host" in /.../wp-includes/canonical.php on line 727; PHP message: PHP Warning: Undefined array key "host" in /.../wp-includes/canonical.php on line 730; PHP message: PHP Warning: Undefined array key "scheme" in /.../wp-includes/canonical.php on line 751; PHP message: PHP Warning: Undefined array key "host" in /.../wp-includes/canonical.php on line 716; PHP message: PHP Warning: Undefined array key "host" in /.../wp-includes/canonical.php on line 727; PHP message: PHP Warning: Undefined array key "host" in /.../wp-includes/canonical.php on line 730; PHP message: PHP Warning: Undefined array key "scheme" in /.../wp-includes/canonical.php on line 751" while reading response header from upstream, client: x.x.x.x, server: stocksrecords.com, request: "GET /secret HTTP/3.0", upstream: "fastcgi://unix:/run/php/php8.3-fpm.sock:"
Change History (7)
This ticket was mentioned in PR #7726 on WordPress/wordpress-develop by @geekofshire.
5 weeks ago
#2
- Keywords has-patch added
#3
@
5 weeks ago
I implemented fallbacks for the host and scheme keys, setting them to "" and 'http' respectively when missing, but unfortunately, this didn’t resolve the issue. Could someone point me in the right direction or suggest an alternative approach?
#5
@
4 weeks ago
Welcome to Trac, @morebrackets, and thanks for the report!
This seems like it could be treated as a duplicate of #34353, where there have been a few attempts at a patch. Would you and @geekofshire mind taking a look at that ticket to confirm? I believe that reproducing the error outside specific environments and setting up test coverage were some of the recent blockers to moving it forward.
#7
@
3 weeks ago
- Focuses php-compatibility removed
- Keywords needs-patch removed
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
- Version 6.6.2 deleted
Duplicate of #34353.
Thanks for confirming, @geekofshire -- I agree and will close this as a dupe. This ticket can always be opened again if new details surface.
This PR addresses PHP warnings in the WordPress canonical.php file related to undefined host and scheme array keys, particularly in environments using HTTP/3 (QUIC) with Nginx, where these headers may be inconsistently set.
To resolve these warnings, fallback values have been introduced for the host and scheme keys as follows:
host
: Defaults to an empty string () if not set. This prevents undefined key errors while allowing flexibility in URL handling logic.scheme
: Defaults to 'http' if not set. This ensures URLs are built with a valid protocol if the scheme is missing.These changes prevent PHP warnings while maintaining backward compatibility across HTTP/1.1, HTTP/2, and HTTP/3 requests.
Trac ticket: https://core.trac.wordpress.org/ticket/62334