Make WordPress Core

Opened 4 years ago

Last modified 3 weeks ago

#39827 reviewing defect (bug)

notice in wp-includes/canonical.php:392

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



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


  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 4 years ago.
Avoid notice on non-existing key.

Download all attachments as: .zip

Change History (11)

#1 @SergeyBiryukov
4 years ago

  • Component changed from General to Canonical

#2 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 4.8

#4 @jipmoors
4 years 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.

4 years ago

Avoid notice on non-existing key.

#5 @jipmoors
4 years ago

  • Keywords has-patch needs-testing added

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

4 years ago

#7 @obenland
4 years ago

  • Milestone changed from 4.8 to Future Release

#8 @SergeyBiryukov
3 weeks ago

#52864 was marked as a duplicate.

#10 @SergeyBiryukov
3 weeks ago

  • Milestone changed from Future Release to 5.8
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing
Note: See TracTickets for help on using tickets.