WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 3 weeks ago

#39827 reopened defect (bug)

notice in wp-includes/canonical.php:392

Reported by: jakubbis Owned by: SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7.2
Component: Canonical Keywords: has-patch needs-testing needs-unit-tests
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 5 years ago.
Avoid notice on non-existing key.

Download all attachments as: .zip

Change History (21)

#1 @SergeyBiryukov
5 years ago

  • Component changed from General to Canonical

#2 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 4.8

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

@jipmoors
5 years ago

Avoid notice on non-existing key.

#5 @jipmoors
5 years ago

  • Keywords has-patch needs-testing added

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


5 years ago

#7 @obenland
5 years ago

  • Milestone changed from 4.8 to Future Release

#8 @SergeyBiryukov
9 months ago

#52864 was marked as a duplicate.

#10 @SergeyBiryukov
9 months ago

  • Milestone changed from Future Release to 5.8
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.


7 months ago

This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.


6 months ago

This ticket was mentioned in Slack in #core-test by francina. View the logs.


6 months ago

#14 @hellofromTonya
6 months ago

  • Keywords needs-unit-tests added
  • Milestone changed from 5.8 to 5.9

Today is 5.8 Beta 1. As there's been no activity, punting to 5.9.

This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.


6 months ago

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


6 weeks ago

#17 @sayedulsayem
6 weeks ago

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

There is no need to assign an empty string after empty checking. Going to close this ticket. from bug scrub discussion.

#18 @SergeyBiryukov
6 weeks ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

It looks like there was some confusion during the bug scrub, as someone thought the problem is already solved in lines 83-85 of canonical.php.

However, that part was introduced in [9506] and adjusted in [13866]. It already existed when this ticket was created. The patch here touches a different area of the code, after the parse_url() call in line 568 further down.

The ticket still seems valid. Reopening for additional review.

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


3 weeks ago

#20 @audrasjb
3 weeks ago

  • Milestone changed from 5.9 to Future Release

As per today's bug scrub, it appears this ticket needs investigating to confirm the problem is there. If yes, then manual and automated testing. Moving for Future release consideration for now.

Note: See TracTickets for help on using tickets.