Make WordPress Core

Opened 9 months ago

Closed 9 months ago

Last modified 9 months ago

#63733 closed defect (bug) (fixed)

Undefined array key "path" error coming from dynamically generated redirect paths

Reported by: chrismattix's profile chrismattix Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Canonical Keywords: has-patch
Focuses: Cc:

Description

We use Sentry to monitor errors on WP sites, and we keep getting a warning coming from the canonical.php file line 619 for "Undefined array key "path"". This warning triggers at random times, and seems to be related to the dynamic nature of these paths. Is there a way to update or alter the canonical.php file to get this error to go away?

Attachments (1)

63733.diff (566 bytes) - added by johnjamesjacoby 9 months ago.

Download all attachments as: .zip

Change History (5)

#1 @johnjamesjacoby
9 months ago

  • Milestone changed from Awaiting Review to 6.9
  • Owner set to johnjamesjacoby
  • Status changed from new to assigned

This may happen if $redirect_url is "seriously malformed" causing the parse_url() calls on either line 578 or 597 to return false.

It also may have revealed itself due to error suppression being removed as part of #49980.

I think the easiest fix is to redo what already happens at the top of redirect_canonical(). Patch imminent.

This ticket was mentioned in PR #9296 on WordPress/wordpress-develop by @dhruvang21.


9 months ago
#2

  • Keywords has-patch added

#3 @johnjamesjacoby
9 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 60496:

Canonical: prevent possible "Undefined array key" PHP error in redirect_canonical(), if the path or query array keys have gone missing.

This commit checks for the existence of (and re-adds if necessary) the path and query array keys after the $redirect variable has potentially been replaced by a second call to parse_url().

This may happen when redirecting back to the root domain, without any path ('/example/) or query (?example=1`) to parse.

Props chrismattix, dhruvang21.

Fixes #63733.

Last edited 9 months ago by johnjamesjacoby (previous) (diff)

#4 @SirLouen
9 months ago

@johnjamesjacoby have you seen #63316 by any chance? (it also includes host in the mix)

Last edited 9 months ago by SirLouen (previous) (diff)
Note: See TracTickets for help on using tickets.