Parses the term_id as an integer in Elastic_Press class

Sometimes the $term['key'] value is a numeric string, causing
the method Tainacan\Repositories\Terms::fetch to return an array
This commit is contained in:
Rafael Chaves Freitas 2020-05-07 21:32:39 -03:00
parent 86af70d8a4
commit 9aa0ebc4aa
1 changed files with 1 additions and 1 deletions

View File

@ -649,7 +649,7 @@ class Elastic_Press {
$taxonomy_slug = $description_types[2]; $taxonomy_slug = $description_types[2];
$taxonomy_id = Repositories\Taxonomies::get_instance()->get_id_by_db_identifier($taxonomy_slug); $taxonomy_id = Repositories\Taxonomies::get_instance()->get_id_by_db_identifier($taxonomy_slug);
foreach ($aggregation[$key]['buckets'] as $term) { foreach ($aggregation[$key]['buckets'] as $term) {
$term_id = $term['key']; $term_id = intval($term['key']);
$term_object = \Tainacan\Repositories\Terms::get_instance()->fetch($term_id, $taxonomy_slug); $term_object = \Tainacan\Repositories\Terms::get_instance()->fetch($term_id, $taxonomy_slug);
$count_query = $wpdb->prepare("SELECT COUNT(term_id) FROM $wpdb->term_taxonomy WHERE parent = %d", $term_id); $count_query = $wpdb->prepare("SELECT COUNT(term_id) FROM $wpdb->term_taxonomy WHERE parent = %d", $term_id);
$total_children = $wpdb->get_var($count_query); $total_children = $wpdb->get_var($count_query);