Trying to get property ‘term_id’ of non-object
-
Hello!
I noticed on a client site that if you delete a category, an SQL error is generated that causes no posts to show for the user in the admin panel, because it fails getting the term ID from a non-existent category and causes invalid SQL. I guess this happens if custom Restrict Taxonomies configurations have been previously saved with that category ID.
There are two instances of this line in restrict-taxonomies.php, lines 655 and 676:
$term_id = get_term_by( ‘slug’, $category, $taxonomy)->term_id;
If you change it to the code below, this goes away as it prevents categories which no longer exist from being added to the category list array.
if (!$term = get_term_by( ‘slug’, $category, $taxonomy )) continue;
$term_id = $term->term_id;Is this change something that can be added to the plugin in the next update? Or an alternate solution for allowing categories to be deleted that may exist in the configuration settings for roles/users?
Thanks!
- The topic ‘Trying to get property ‘term_id’ of non-object’ is closed to new replies.