[wp-trac] [WordPress Trac] #40309: Notice: in canonical.php line 122

WordPress Trac noreply at wordpress.org
Thu Mar 30 09:20:21 UTC 2017


#40309: Notice: in canonical.php line 122
--------------------------+-----------------------------
 Reporter:  bobbingwide   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Canonical     |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 === 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

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40309>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list