Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#50046 new defect (bug)

lack table selector in `_update_post_term_count`

Reported by: yaquawa's profile yaquawa Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4
Component: Taxonomy Keywords:
Focuses: Cc:

Description

The function _update_post_term_count in wp-includes/taxonomy.php query the db without table selector.

<?php
$count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode( "', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );

This cause problem if who added a column named post_type in the $wpdb->term_relationships table, because the table $wpdb->posts has a column called post_type too.

Please quantify the column with the table name like $wpdb->posts.post_type.

Change History (1)

#1 @SergeyBiryukov
5 years ago

  • Component changed from General to Taxonomy
Note: See TracTickets for help on using tickets.