[wp-trac] [WordPress Trac] #42361: get_term returns NULL before filters

WordPress Trac noreply at wordpress.org
Fri Oct 27 19:10:56 UTC 2017


#42361: get_term returns NULL before filters
-------------------------+-----------------------------
 Reporter:  socki03      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Taxonomy     |    Version:  4.7
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 So, this might be a super specific issue, but we utilize a plugin called
 CPT-onomies [https://wordpress.org/plugins/cpt-onomies/], which modifies
 CPTs to be also utilized as taxonomies, which means it manipulates the
 system in a few ways, but, for the most part it's been working great!

 Ever since the taxonomy changes that came about somewhere between 4.5 -
 4.7, error log files have been sort of exploding due to object term caches
 being full of NULL values.  I believe I've come up with a fix to that
 solution outside of core, but I have come across an issue with the
 function `get_term`.

 This chunk of code is run around lines 746-750:
 {{{
         if ( is_wp_error( $_term ) ) {
                 return $_term;
         } elseif ( ! $_term ) {
                 return null;
         }
 }}}

 before any filters are run on $_term, mainly, on line 761:

 {{{
     $_term = apply_filters( 'get_term', $_term, $taxonomy );
 }}}

 I know I might be a bit out of my depth, but is there a reason that NULL
 is returned if the `$_term` is false before the filters are run?

 I understand the return if a WP_Error is encountered, but if there is a
 different pairing that is needed outside the what the core interprets as a
 Term/Taxonomy relationship, could that if false/return null be run after
 the filters?

 Thanks for bearing with me through this!

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42361>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list