[wp-trac] [WordPress Trac] #34353: redirect_canonical() – Undefined indexes 'host' and 'scheme'
WordPress Trac
noreply at wordpress.org
Wed Jul 12 11:28:55 UTC 2023
#34353: redirect_canonical() – Undefined indexes 'host' and 'scheme'
-------------------------------------------------+-------------------------
Reporter: theamila | Owner: (none)
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Future
| Release
Component: Canonical | Version: 4.3.1
Severity: normal | Resolution:
Keywords: needs-unit-tests has-patch needs- | Focuses:
testing-info |
-------------------------------------------------+-------------------------
Comment (by fibrojedi):
Replying to [comment:55 nestormarius]:
> I've also applied the diff from @oglekler and now my error_log file only
outputs this warning.
>
>
> {{{
> Undefined array key "path" in /home/xxx/public_html/wp-
includes/canonical.php on line 710
> }}}
>
> Line 710 shows
> {{{
> $compare_original = array( $original['host'], $original['path'] );
> }}}
>
> Later edit: I forgot to mention that in the original canonical.php file
line 710 is actually line 701, so it won't confuse anyone.
>
> Any idea how to fix it?
> Thanks!
>
> Later edit: I reverted the changes as the diff breaks things in my
WordPress site.
I also just tried the patch and the errors are
{{{
[12-Jul-2023 11:18:56 UTC] PHP Warning: Undefined array key "host" in
/mnt/1c88b8d1-c48e-4b2e-92b3-89e869e10559/fibrojedi.me.uk/wp-
includes/canonical.php on line 706
[12-Jul-2023 11:18:56 UTC] PHP Warning: Undefined array key "host" in
/mnt/1c88b8d1-c48e-4b2e-92b3-89e869e10559/fibrojedi.me.uk/wp-
includes/canonical.php on line 715
}}}
Those lines in canonical.php are
{{{
706: $original_host_low = strtolower( $original['host'] );
715: $redirect['host'] = $original['host'];
}}}
I'm on PHP8.2 in case it helps anyone. It seems `$redirect['host']`
doesn't trigger it (as line 707 isn't flagged as containing an error, but
`$original['host']` does trip the error.
I'm happy to test anything as these warnings fill up my error logs, but I
don't want to suppress warnings either.
Thanks.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34353#comment:57>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list