Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/05/2020 05:57:36 PM (4 years ago)
Author:
johnjamesjacoby
Message:

Meta: always query meta_value by string, not by integer.

This commit swaps "%d" for "%s" when querying by meta_value, even with numeric values. This allows for custom index alterations to perform as intended, and also more closely follows how WordPress core itself operates.

In trunk, for 2.7. Fixes #3408.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/tools/upgrade.php

    r7006 r7150  
    427427
    428428            // Skip if already exists
    429             if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, $new_key, $meta->user_id ) ) ) {
     429            if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %s", $post_id, $new_key, $meta->user_id ) ) ) {
    430430                continue;
    431431            }
     
    487487
    488488            // Skip if already exists
    489             if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, $new_key, $meta->user_id ) ) ) {
     489            if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %s", $post_id, $new_key, $meta->user_id ) ) ) {
    490490                continue;
    491491            }
     
    547547
    548548            // Skip if already exists
    549             if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, $new_key, $meta->user_id ) ) ) {
     549            if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %s", $post_id, $new_key, $meta->user_id ) ) ) {
    550550                continue;
    551551            }
Note: See TracChangeset for help on using the changeset viewer.