[wp-trac] [WordPress Trac] #59785: Fatal error: Attempt to assign property “object_id” on bool in class-wp-term-query.php
WordPress Trac
noreply at wordpress.org
Fri Nov 3 11:16:34 UTC 2023
#59785: Fatal error: Attempt to assign property “object_id” on bool in class-wp-
term-query.php
--------------------------+------------------------------
Reporter: Faar | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 6.3.3
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by Faar):
This solved the Error:
{{{#!php
<?php
protected function populate_terms( $terms ) {
$term_objects = array();
if ( ! is_array( $terms ) ) {
return $term_objects;
}
foreach ( $terms as $key => $term_data ) {
if ( is_object( $term_data ) && property_exists(
$term_data, 'term_id' ) ) {
$term = get_term( $term_data->term_id );
if ( is_object( $term ) &&
property_exists( $term_data, 'object_id' ) ) { // modfied 2023_10_26 Faar:
is_object()
$term->object_id = (int) $term_data->object_id;
}
if ( property_exists( $term_data, 'count'
) ) {
$term->count = (int)
$term_data->count;
}
} else {
$term = get_term( $term_data );
}
if ( $term instanceof WP_Term ) {
$term_objects[ $key ] = $term;
}
}
return $term_objects;
}
}}}
Asking, if is object $term.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59785#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list