WordPress.org

Make WordPress Core

Opened 17 months ago

Last modified 13 months ago

#39827 new defect (bug)

notice in wp-includes/canonical.php:392

Reported by: jakubbis Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7.2
Component: Canonical Keywords: has-patch needs-testing
Focuses: Cc:

Description

Hello,

We're getting notice in wp-includes/canonical.php:392, but it requires some specific steps to obtain it.

Steps:

  1. Setup a clean install of WPML
  2. Set permalinks to postname without ending slash: /%postname%
  3. Create a page in secondary language
  4. Set this page as Home Page (under Settings/Reading) but only in the secondary language

When you enter "home page", you get 404 because a page for original language does not exist. In line 121, you get $redirect_url = get_permalink($redirect_post); and value of $redirect_url is for instance "http://testsite.dev?lang=fr". As you see, there is no "/" before "?", that's why path is empty.

You have already fixed the similar issue in line:77-79

// Notice fixing
if ( !isset($redirect['path']) )
   $redirect['path'] = '';

I suspect, we need the same fix before line: 392

$redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']);

Attachments (1)

39827.diff (1.0 KB) - added by jipmoors 15 months ago.
Avoid notice on non-existing key.

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
17 months ago

  • Component changed from General to Canonical

#2 @SergeyBiryukov
17 months ago

  • Milestone changed from Awaiting Review to 4.8

#4 @jipmoors
15 months ago

Hi @jakubbis,

Thank you for submitting this report and the detailed information with it.

I have taken a look at the file and the locations you mentioned and I have determined where this problem is coming from. There are two error suppressed calls to parse_url which both can cause this issue.

@jipmoors
15 months ago

Avoid notice on non-existing key.

#5 @jipmoors
15 months ago

  • Keywords has-patch needs-testing added

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


13 months ago

#7 @obenland
13 months ago

  • Milestone changed from 4.8 to Future Release
Note: See TracTickets for help on using tickets.