Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#37298 closed defect (bug) (duplicate)

unregistered CPT archive link in menu breaks nav/menu admin screen

Reported by: littlerchicken's profile littler.chicken Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.6
Component: Menus Keywords:
Focuses: Cc:


If you have a registered CPT and add the Post Type Archive link to a navigation menu, and then remove the CPT from your site (deactivate the plugin which registers it, for instance), then the admin screen for editing menus throws this error:

PHP Fatal error:  Cannot use object of type WP_Post_Type as array in .../wp-admin/includes/screen.php on line 123

It's not a total white screen, but adds the above to the error log. In 4.5.3, the page loads properly and does warn of an invalid menu item.

To reproduce, activate a plugin which registers a custom post type. Create an entry so that the "All CPT" (Post Type Archive) link is available for the menu. Add the Post Type Archive link to the menu and save the menu. Deactivate the plugin and then go back to Appearance > Menus.

Not sure how to fix, but wanted to report. Thanks!

Attachments (3)

empty-admin-46.png (16.9 KB) - added by littler.chicken 8 years ago.
Screenshot of the blank Menus page in the admin in 4.6 (RC2)
invalid-menu-item-45.png (154.1 KB) - added by littler.chicken 8 years ago.
(correct) display of invalid menu item in 4.5.3
37298.diff (423 bytes) - added by elrae 8 years ago.
Fix blank menu

Download all attachments as: .zip

Change History (5)

8 years ago

Screenshot of the blank Menus page in the admin in 4.6 (RC2)

8 years ago

(correct) display of invalid menu item in 4.5.3

#1 @elrae
8 years ago

This seems to be a symptom of a larger issue as I am seeing this with a fresh blank install of the nightly build. Can you try the attached diff file and see if that fixes your issue too? After fixing the issue I saw which was the same thing), I could not replicate your issue.

Commit Message ---

Menu: Fix blank screen.

The meta boxes tries to assign a widget title based on the array key and only checks if the value isset, which does not validate as false when the item is an object. This checks to makes sure the item we check against is an array first.

Fixes #37298.

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

8 years ago

Fix blank menu

#2 @swissspidy
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Thanks for reporting this and for the patch!

This was introduced with #35021, so I'm closing this ticket in favour of the original one.

At the thame the patch for that ticket was written, there was no WP_Post_Type class. It was just an object, which PHP probably silently casted to an array.

Note: See TracTickets for help on using tickets.