Closed davejesch closed 4 years ago
In doing some testing, I can only make these notices appear if it's a menu item for a a post/page that doesn't exist on the target site. Is this the case when this bug was found or was it at other times?
What should happen when a user tries to sync a menu with links to non-existing posts/pages on the target site? Prevent syncing and show an error?
Ah, the "missing page" is the clue.
On my Target, all the pages exist - but they're probably using different post IDs. So when I view the menu, the post IDs don't exist and they're seen as "missing."
We need to use the wp_spectrom_sync table [SyncModel->get_sync_data(source_id, source_site_key, 'post') ] to look up the site_key and source_content_id and content_type='post' ('post' in this case includes both posts and pages and refers to the wp_posts table, not a post_type value) of the Source and then modify the post->ID value to the target_content_id value from that table.
We need to do these lookups first and if there is no target_content_id value found for the menu item, we should not create any content on the Target and return an error code with a message of "Some of the Content in the menu is missing on the Target. Please push these Pages to the Target before Syncing this menu." ...and then list the post_title values of the missing pages. These can be returned via the 2nd 'data' parameter provided in the SyncApiResponse->error_code($code, $list_of_pages) method call.
I have added the lookups, however, I'm having trouble returning the list of missing pages to the ajax response. It's in the ~log.txt file, but I'm not sure how to make it show up in the response. console.log is not showing error_data in the response.
This issue has been resolved
STEPS TO REPRODUCE:
RESULT:
The following error messages are displayed at the top of the page: Notice: Trying to get property of non-object in wp-includes/nav-menu.php on line 752 Notice: Trying to get property of non-object in wp-includes/nav-menu.php on line 752 Notice: Trying to get property of non-object in wp-includes/nav-menu.php on line 756
And this error message is displayed between the first and second menu items displayed within the Menu Structure area on the right pane: Notice: Trying to get property of non-object in wp-admin/includes/class-walker-nav-menu-edit.php on line 80
EXPECTED RESULT:
No error messages to be displayed.
WordPress Version: Source: 4.5; Target: 4.5.3 Browser: Chrome Browser Version: Operating System: n/a