[wp-trac] [WordPress Trac] #40878: Adding menus route

WordPress Trac noreply at wordpress.org
Mon Nov 8 03:44:51 UTC 2021


#40878: Adding menus route
-------------------------------------------------+-------------------------
 Reporter:  dingo_d                              |       Owner:
                                                 |  spacedmonkey
     Type:  task (blessed)                       |      Status:  assigned
 Priority:  high                                 |   Milestone:  5.9
Component:  REST API                             |     Version:  4.7
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-dev-  |     Focuses:  rest-api
  note                                           |
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:60 TimothyBlynJacobs]:
 > @SergeyBiryukov, @welcher, @audrasjb I'd love your thoughts on
 comment:58. In particular, this could be interpreted as a BC break. If
 those calls fail to update, is this a catastrophic error that should stop
 the rest of the process from happening?

 At a glance, both of the suggested changes seem fine. There is a similar
 return if `wp_insert_post()` fails [source:tags/5.8.1/src/wp-includes/nav-
 menu.php?marks=530-532#L525 just a few lines above]. If the
 `wp_set_object_terms()` or `wp_update_post()` call fails, it seems unsafe
 to proceed as that could lead to data discrepancies.

 It's worth noting, however, that for the `is_wp_error()` condition to
 work, `wp_update_post()` should be called with the `$wp_error` parameter
 set to `true`, as it's `false` by default. The same applies to the check
 linked above: I think the `is_wp_error( $menu_item_db_id )` part doesn't
 work as expected, as `wp_insert_post()` never returns a `WP_Error` object
 unless the `$wp_error` parameter is `true`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/40878#comment:68>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list