You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under the right conditions (or wrong conditions, depending on how you look at it), get_connected_[*]_objects() returns a WP_Error object that results in a SQL error:
Warning: implode(): Invalid arguments passed in /wp-includes/query.php on line 2658
WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND wp_posts.post_type = 'post' AND (wp_posts.post_status = ' at line 1 for query SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.ID IN () AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 3 made by WP_Query::get_posts/
An example of how this can happen is if you want to set up a "related posts" section for the post post type in single.php:
If you don't check that 'post' !== get_post_type() then you will get the WP_Error object returned on all custom post type single posts.
One fix for this would be to just return an empty array() instead of the WP_Error object, but that doesn't address the need to notify the developer that they may be using the wrong post type (perhaps throw a PHP Warning or Notice?).
The text was updated successfully, but these errors were encountered:
Under the right conditions (or wrong conditions, depending on how you look at it),
get_connected_[*]_objects()
returns aWP_Error
object that results in a SQL error:Warning: implode(): Invalid arguments passed in /wp-includes/query.php on line 2658
WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND wp_posts.post_type = 'post' AND (wp_posts.post_status = ' at line 1 for query SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.ID IN () AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 3 made by WP_Query::get_posts/
An example of how this can happen is if you want to set up a "related posts" section for the
post
post type insingle.php
:If you don't check that
'post' !== get_post_type()
then you will get theWP_Error
object returned on all custom post type single posts.One fix for this would be to just return an empty
array()
instead of theWP_Error
object, but that doesn't address the need to notify the developer that they may be using the wrong post type (perhaps throw a PHP Warning or Notice?).The text was updated successfully, but these errors were encountered: