WordPress.org

Make WordPress Core

#39317 closed defect (bug) (invalid)

Trying to get property of non-object wp_terms_checklist

Reported by: jevuska Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: Taxonomy Keywords: reporter-feedback
Focuses: administration Cc:

Description

I set wp_debug true and use filter wp_terms_checklist_args, it showing error when set argument descendants_and_self to true.

Change History (3)

#1 follow-up: @boonebgorges
13 months ago

  • Component changed from General to Taxonomy
  • Focuses administration added
  • Keywords reporter-feedback added

Hi @jevuska - Can you share some additional details? What is the code you're using to filter wp_terms_checklist_args? Are you modifying a default WP taxonomy, or a custom one? What is the full text of the "Trying to get property..." error (including line number and backtrace, if possible)?

#2 in reply to: ↑ 1 @jevuska
13 months ago

Replying to boonebgorges:

Hi @jevuska - Can you share some additional details? What is the code you're using to filter wp_terms_checklist_args? Are you modifying a default WP taxonomy, or a custom one? What is the full text of the "Trying to get property..." error (including line number and backtrace, if possible)?

Hi @boonebgorges, thanks for response, here my code, just for testing,

add_filter( 'wp_terms_checklist_args', function( $args, $post_id )
{
 if ( is_admin() )
   $args['descendants_and_self'] = true;
				
 return $args;
}, 1, 2 );

With notice:

Notice: Trying to get property of non-object in ...\wp-admin\includes\template.php on line 156
Last edited 13 months ago by jevuska (previous) (diff)

#3 @boonebgorges
13 months ago

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

@jevuska Thanks for the clarification. On closer examination, it appears that you're using descendants_and_self incorrectly. This parameter expects a term ID, not a boolean. If you pass it 53, it'll return term 53 and all descendants. true gets cast to 1, and you're probably seeing the notice because you're getting a WP_Error or some other weird response back (maybe because you deleted term 1).

See https://core.trac.wordpress.org/browser/tags/4.7/src/wp-admin/includes/template.php?marks=63-64#L50 for more info on the parameter.

Note: See TracTickets for help on using tickets.