WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#34449 closed defect (bug) (fixed)

Remove CPT if exists menu item

Reported by: sebastian.pisula Owned by: swisspiddy
Milestone: 4.4.1 Priority: normal
Severity: normal Version: 4.4
Component: Menus Keywords: fixed-major
Focuses: Cc:
PR Number:

Description

I add to menu Post Type Archive URL and i remove function register_post_type(). And i have notice:

Notice: Trying to get property of non-object in D:\xampp\htdocs\wordpress\wp-admin\includes\class-walker-nav-menu-edit.php on line 83

Error is in line $original_title = $original_object->labels->archives; because post object not exists

Attachments (4)

34449.patch (874 bytes) - added by sebastian.pisula 4 years ago.
34449.2.patch (1.7 KB) - added by sebastian.pisula 4 years ago.
screen.png (82.7 KB) - added by sebastian.pisula 4 years ago.
screen with error in menu
34449.3.diff (1.4 KB) - added by kucrut 4 years ago.
Refresh patch

Download all attachments as: .zip

Change History (15)

#1 @sebastian.pisula
4 years ago

I found error during save menu if CPT object not exists:

Notice: Trying to get property of non-object in wp-includes\nav-menu.php on line 408

#2 @sebastian.pisula
4 years ago

  • Keywords has-screenshots added
  • Severity changed from normal to major

Error still exists. I have plugin where I register post type. In menu add item "Post Type Archive". When I turn off my plugin in menu manager I have notice:

Notice: Trying to get property of non-object in /wp-admin/includes/class-walker-nav-menu-edit.php on line 83

Notice: Trying to get property of non-object in /wp-admin/includes/class-walker-nav-menu-edit.php on line 83

In attachment is screen of bug. My patch fixes this.

@sebastian.pisula
4 years ago

screen with error in menu

#3 @sebastian.pisula
4 years ago

  • Keywords has-patch added
  • Version set to 4.4

This ticket was mentioned in Slack in #core by sebastian.pisula. View the logs.


4 years ago

#5 @swissspidy
4 years ago

  • Keywords needs-testing added
  • Severity changed from major to normal

Apart from the assignment in the condition the patch makes sense to me. Will test.

Related: #13958

#6 @swissspidy
4 years ago

  • Milestone changed from Awaiting Review to 4.4.1

@kucrut
4 years ago

Refresh patch

#7 @jorbin
4 years ago

  • Owner set to swisspiddy
  • Status changed from new to assigned

@swisspiddy thanks for looking into this. Please update with anything you find.

#8 @swissspidy
4 years ago

  • Keywords commit added; needs-testing removed

The latest patch works great. No notices are shown.

#9 @dd32
4 years ago

In general PHP Notices are not normally something that goes into a point release, as you shouldn't be running with display_errors enabled on a production site. Notices are not displayed by default.

#10 @dd32
4 years ago

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

In 36095:

Nav Menus: Avoid a PHP Notice when a menu contains a now unregistered post type archive.

Props kucrut.
Fixes #34449 for trunk.

#11 @dd32
4 years ago

  • Keywords fixed-major added; has-screenshots has-patch commit removed

re-opening for 4.4.1 consideration, based on the above, does anyone feel that it's a common scenario for a user to run into?

Especially considering PHP notices should require WP_DEBUG to be on and display_errors to be enabled in production.

Note: See TracTickets for help on using tickets.