Unsafe SQL calls
-
I create one custom plugin and submit for review
bellow is issues found by wordpress teamincludes/databases/class-stepup-user-crud.php:313 $sql_orders = $wpdb->prepare( " SELECT p.* FROM {$db->tb_posts} p INNER JOIN {$db->tb_postmeta} pm ON p.ID = pm.post_id AND meta_key = %s AND (meta_value = %d OR meta_value like '%s') ", '_user_id', $user_id, $user_id_str ); includes/databases/class-stepup-user-crud.php:338 $sql = $sql_orders /* . ' UNION ' . $sql_guest_orders */ . $sql_rest; includes/databases/class-stepup-user-crud.php:341 $order_posts = $db->wpdb->get_results($sql);# There is a call to a wpdb::prepare() function, that's correct. # You cannot add variables like "$db->tb_posts" directly to the SQL query. # Using wpdb::prepare($query, $args) you will need to include placeholders for each variable within the query and include the variables in the second parameter. # The SQL query needs to be included in a wpdb::prepare($query, $args) function.I do not understand problem in these like “You cannot add variables like “$db->tb_posts” directly to the SQL query.” I have one global variable define for
$db->tb_posts.
so please help me
You must be logged in to reply to this topic.