Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #40878, comment 68


Ignore:
Timestamp:
11/08/2021 03:50:11 AM (2 years ago)
Author:
SergeyBiryukov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #40878, comment 68

    initial v1  
    44At 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.
    55
    6 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`.
     6It'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 in [source:tags/5.8.1/src/wp-includes/nav-menu.php?marks=530-532#L525 line 530] doesn't work as expected, as `wp_insert_post()` never returns a `WP_Error` object unless the `$wp_error` parameter is `true`.