WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#40542 closed defect (bug) (fixed)

Undefined index in strip_fragment_from_url function

Reported by: betterstudio Owned by: DrewAPicture
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.4
Component: Canonical Keywords: has-patch dev-feedback
Focuses: Cc:

Description

There is undefined index in strip_fragment_from_url function for

 $parsed_url['path']

path should be checked to be available. Simple check needed:

if ( ! empty( $parsed_url['path'] ) )

file: wp-includes/canonical.php line 570

Attachments (1)

40542.diff (515 bytes) - added by Mte90 3 years ago.

Download all attachments as: .zip

Change History (8)

#1 @ocean90
3 years ago

  • Component changed from General to Canonical
  • Keywords reporter-feedback added
  • Version changed from trunk to 4.4

Hello @betterstudio, welcome to WordPress Trac!

So far strip_fragment_from_url() is only used in redirect_canonical(). What URL are you trying to access to get this warning?

#2 @betterstudio
3 years ago

Hi @ocean90
I can't remember it now because i saw it 6 week ago in one of our customers site!

It does not matter! You can check this code: {{{#!php
<?php

strip_fragment_from_url( 'http://betterstudio.com' );

}}}

That function will make a warning!

Notice: Undefined index: path in .../wp.dev/wp-includes/canonical.php on line 570

#3 @SergeyBiryukov
3 years ago

  • Keywords needs-patch added; reporter-feedback removed

@Mte90
3 years ago

#4 @Mte90
3 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed

In the function the other array index are checked except this one so as suggested on the ticket this will avoid problems :-)

This ticket was mentioned in Slack in #core by mte90. View the logs.


3 years ago

#6 @DrewAPicture
3 years ago

  • Owner set to DrewAPicture
  • Resolution set to fixed
  • Status changed from new to closed

In 41257:

Canonical: Check first before attempting to include a 'path' value in the URL in strip_fragment_from_url().

Props Mte90.
Fixes #40542.

#7 @DrewAPicture
3 years ago

  • Milestone changed from Awaiting Review to 4.9
Note: See TracTickets for help on using tickets.