Minor bug: Appends a NULL to the term meta cache
-
I’ve tried to post it as bug report on the Hypestudio contact/help page (as suggested here by Dejan), but the form refuses to send (probably my browser causing this).
So, if you turn DEBUG to TRUE in wp-config.php, you get two warning Notices for every post that WP loops through, if it has a CPT-onomy-term. (So on an Archive page that can be hundreds or thousands, on a single Post/Page that’s just two.)
The specific notice is always:
Notice: Trying to get property ‘term_id’ of non-object in [your_webroot]/wp-includes/post.php on line 6736
Notice: Trying to get property ‘term_id’ of non-object in [your_webroot]/wp-includes/post.php on line 6737You can test this by installing a blank WP, installing the plugin, making a CPT (e.g., “Country”) via the plugin (just a name, label and apply to e.g. “post”) and making one instance of this CPT (e.g., “Australia”), then in Admin use the plugin to link the custom post “Australia” to the default “Hello World!”-post: The warning will appear when you refresh your frontpage. Deactivate plugin and the warning disappears.
So, if you go to that post.php line from the warning and insert a var_dump(..); line or two on the variables in question, you learn from the output that CPT-onomies inserts a NULL into (line 6732)
$terms = get_object_term_cache( $post->ID, $taxonomy );
So the temporary solution (until the next update of WordPress overwrites it!) is to change line 6735 from
if ( ! isset( $term_ids[ $term->term_id ] ) ) {
(using $term != NULL && ) into
if ( $term != NULL && ! isset( $term_ids[ $term->term_id ] ) ) {
But editing core WP files is not the answer, clearly… I have no idea at exactly which point CPTonomy accidentally inserts the NULL and/or whether WordPress should actually always test for NULL at that point.
- The topic ‘Minor bug: Appends a NULL to the term meta cache’ is closed to new replies.