Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#38945 closed defect (bug) (fixed)

Menu customizer : adding a term item to a menu creates a fatal error when previewing the changeset

Reported by: nikeo's profile nikeo Owned by: westonruter's profile westonruter
Milestone: 4.7 Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords: has-patch has-unit-tests commit
Focuses: Cc:

Description

Configuration

  • Version of WP : 4.7 RC1-39355
  • Browser : Chrome
  • PHP Version : 7.0.11
  • MySQL Version : 5.5.52

Here's how to reproduce the problem :

  1. Open the customizer
  2. Expand the menu section
  3. Click on an existing menu or create a new one ( it makes no differences )
  4. Then click on add item and pick a term, either a category or a tag
  5. Select a location for this menu if not already done

The javascript console show an error message (see attachment 1 )

Then when refreshing the browser, like if I was coming back to my customized changeset, the following fatal error message is displayed ( see attachment 2 ) :
Catchable fatal error: Object of class WP_Error could not be converted to string in /srv/www/wp-betas/htdocs/wp-includes/formatting.php on line 3767

It seems that a string passed to esc_url() function at some point (when ?) is actually a WP_Error object.

Attachments (4)

2016-11-26_09-27-24.png (24.1 KB) - added by nikeo 8 years ago.
attachment_1
2016-11-26_09-24-48.png (76.9 KB) - added by nikeo 8 years ago.
attachment_2
38945.0.diff (802 bytes) - added by westonruter 8 years ago.
38945.1.diff (3.9 KB) - added by westonruter 8 years ago.
https://github.com/xwp/wordpress-develop/pull/205

Download all attachments as: .zip

Change History (12)

@nikeo
8 years ago

attachment_1

@nikeo
8 years ago

attachment_2

@westonruter
8 years ago

#1 @westonruter
8 years ago

  • Keywords has-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to 4.7
  • Owner set to westonruter
  • Status changed from new to accepted

@nikeo great catch! This was introduced in r38991 as part of #38114 in the \WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() method to ensure nav menu item URL is set according to linked object. There was a typo in how in that it was passing object instead of object_id into get_term_link(). Please give 38945.0.diff a try.

#2 @nikeo
8 years ago

OK got it thanks.
The patch fixes it!
Ticket closed.

Last edited 8 years ago by nikeo (previous) (diff)

#3 @westonruter
8 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed

@nikeo please also test 38945.1.diff. I found that the logic for previewing the URL for post type archive links was also failing.

#4 @nikeo
8 years ago

OK give me a few minutes

#5 @nikeo
8 years ago

@westonruter your latest patch works fine on my side.
I've registered a CPT with a custom tax, everything went fine, before and after the latest patch.

I could create and preview customized changesets with CPT menu items and custom terms items. I couls aslo preview the CPT page and the custom archive page without any problems showing up.
hope it helps !

#6 @aaroncampbell
8 years ago

  • Keywords commit added

I was able to recreate the issue, and verify that 38945.1.diff fixes it and looks sane (also fixing the same issue with post type archives).

+1 on commit.

#7 @westonruter
8 years ago

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

In 39365:

Customize: Fix logic for previewing the URL for nav_menu_item settings for terms and post type archives.

Fixes typo in args passed to get_term_link() which caused a fatal error due to this call returning a WP_Error which was set to url. Also fixes never-satisfiable condition for obtaining post type archive URL. Also ensures that WP_Error never leaks through as url by setting it to an empty string. Adds missing unit tests.

Amends [38991].
See #38114.
Fixes #38945.

#8 @westonruter
8 years ago

In 39366:

Customize: Fix logic for previewing the URL for nav_menu_item settings for terms and post type archives.

Fixes typo in args passed to get_term_link() which caused a fatal error due to this call returning a WP_Error which was set to url. Also fixes never-satisfiable condition for obtaining post type archive URL. Also ensures that WP_Error never leaks through as url by setting it to an empty string. Adds missing unit tests.

Amends [38991].
See #38114.
Fixes #38945 for 4.7.

Note: See TracTickets for help on using tickets.