WordPress.org

Make WordPress Core

Opened 4 months ago

Closed 11 days ago

#49872 closed defect (bug) (fixed)

PHP Notice: Undefined index: path in /wp-includes/functions.php on line 905

Reported by: jbouganim Owned by: SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version: 4.4
Component: Pings/Trackbacks Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

Some URLs here do not have a 'path' and thus throw this notice.
Instead of only checking on /wp-includes/functions.php L904:

<?php
if ( false !== $url_parts )

should also check

<?php
if ( false !== $url_parts && !empty($url_parts['path']) )

Attachments (1)

49872.patch (616 bytes) - added by mukesh27 4 months ago.
Initial patch.

Download all attachments as: .zip

Change History (7)

@mukesh27
4 months ago

Initial patch.

#1 @mukesh27
4 months ago

  • Component changed from General to Pings/Trackbacks
  • Keywords has-patch added
  • Severity changed from minor to normal
  • Version changed from 5.4 to 4.4

Hi, @jbouganim,

Welcome to WordPress Trac! Thanks for the ticket.

Added initial patch as suggested.

#2 @Otto42
4 months ago

Can you provide an example of a URL that would not have a path component?

#3 @jbouganim
4 months ago

@Otto42 Sure.

<?php
$url_parts = parse_url("https://redirect.viglink.com?key=2fb2035e82f6fb61e704bd9&u=https%3A%2F%2Fwww.michaels.com%2Fsearch%3Fq%3Dbandana");

Will not have a path index.

#4 @Otto42
4 months ago

  • Keywords needs-unit-tests added

Great! So probably need some unit tests added to go with this as well.

#5 @SergeyBiryukov
4 months ago

  • Milestone changed from Awaiting Review to 5.5
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#6 @SergeyBiryukov
11 days ago

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

In 48621:

Pings/Trackbacks: Avoid a PHP notice in do_enclose() when encountering a URL without a path in post content.

Props jbouganim, mukesh27, Otto42, SergeyBiryukov.
Fixes #49872.

Note: See TracTickets for help on using tickets.