Opened 11 years ago
Last modified 6 years ago
#28488 new defect (bug)
get_post_type_object on CPT in _count_posts_cache_key after a wp_insert_post returns null
Reported by: | barrykooij | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9.1 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | Cc: |
Description
After running a wp_insert_post
in one of my plugins I got the following notices because get_post_type_object
in _count_posts_cache_key
returns null. I've added a simple not equals null check to the function to prevent these notices.
Backtrace:
Backtrace from warning 'Trying to get property of non-object' at /vagrant/latest/wp-includes/post.php 2188: /vagrant/latest/wp-includes/post.php 5484 calling _count_posts_cache_key() calling _transition_post_status() /vagrant/latest/wp-includes/plugin.php 470 calling call_user_func_array() /vagrant/latest/wp-includes/post.php 3665 calling do_action() /vagrant/latest/wp-includes/post.php 3200 calling wp_transition_post_status() /vagrant/latest/wp-content/plugins/my-plugin/core/classes/class-connection-manager-core.php 34 calling wp_insert_post() /vagrant/latest/wp-content/plugins/my-plugin/core/classes/class-connection-manager-core.php 271 calling add() /vagrant/latest/wp-content/plugins/my-plugin/core/classes/class-admin-menu.php 117 calling save() calling handle_post() /vagrant/latest/wp-includes/plugin.php 470 calling call_user_func_array() /vagrant/latest/wp-admin/admin.php 144 calling do_action() Backtrace from warning 'Trying to get property of non-object' at /vagrant/latest/wp-includes/post.php 2188: /vagrant/latest/wp-includes/post.php 5484 calling _count_posts_cache_key() calling _transition_post_status() /vagrant/latest/wp-includes/plugin.php 470 calling call_user_func_array() /vagrant/latest/wp-includes/post.php 3665 calling do_action() /vagrant/latest/wp-includes/post.php 3200 calling wp_transition_post_status() /vagrant/latest/wp-content/plugins/my-plugin/core/classes/class-connection-manager-core.php 34 calling wp_insert_post() /vagrant/latest/wp-content/plugins/my-plugin/core/classes/class-connection-manager-core.php 271 calling add() /vagrant/latest/wp-content/plugins/my-plugin/core/classes/class-admin-menu.php 117 calling save() calling handle_post() /vagrant/latest/wp-includes/plugin.php 470 calling call_user_func_array() /vagrant/latest/wp-admin/admin.php 144 calling do_action() Backtrace from warning 'Cannot modify header information - headers already sent' at /vagrant/latest/wp-includes/pluggable.php 1121: /vagrant/latest/wp-includes/pluggable.php 1121 calling header() /vagrant/latest/wp-content/plugins/my-plugin/core/classes/class-admin-menu.php 119 calling wp_redirect() calling handle_post() /vagrant/latest/wp-includes/plugin.php 470 calling call_user_func_array() /vagrant/latest/wp-admin/admin.php 144 calling do_action()
Attachments (1)
Change History (8)
#2
@
10 years ago
I am getting this as well. it really should check to see if anything was returned before it checks for an attribute. Any chance of this getting into 4.0?
This ticket was mentioned in IRC in #wordpress-dev by barrykooij. View the logs.
10 years ago
Note: See
TracTickets for help on using
tickets.
I'm getting this too; the patch looks fine.