Opened 8 years ago
Closed 4 years ago
#40309 closed defect (bug) (fixed)
Notice: in canonical.php line 122
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.7 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Canonical | Keywords: | has-patch |
Focuses: | Cc: |
Description
Scenario
- Attempted to access a post using ?p=22781
- Post 22781 exists.
- But it has a post type associated with a plugin that's been deactivated.
Expected result
404 page without a notice
Actual result
404 page with the following Notice
Notice: Trying to get property of non-object in wp-includes\canonical.php on line 122
Explanation
The post_type is not registered so this returns null
$post_type_obj = get_post_type_object($redirect_post->post_type);
Proposed solution
Add test on $post_type_obj.
if ( $post_type_obj && $post_type_obj->public && 'auto-draft' != $redirect_post->post_status ) {
Workaround =
Either re-activate the de-activated plugin, or use the correct post ID... I meant to type ?p=22871
Attachments (3)
Change History (9)
This ticket was mentioned in Slack in #core by obenland. View the logs.
8 years ago
@
4 years ago
Confirm that the reported issue still remains and the suggested patch resolves it. Refreshing against trunk.
Note: See
TracTickets for help on using
tickets.
Test $post_type_obj before accessing public property