Skip to:
Content

bbPress.org

Changeset 5739


Ignore:
Timestamp:
05/13/2015 12:35:49 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Common: Improve type-casting return values in query functions.

Props thebrandonallen, netweb. See #2801.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r5730 r5739  
    15301530
    15311531        $child_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", $parent_id, $post_type ) );
     1532
    15321533        wp_cache_set( $cache_id, $child_id, 'bbpress_posts' );
     1534    } else {
     1535        $child_id = (int) $child_id;
    15331536    }
    15341537
     
    15781581
    15791582        $child_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $parent_id, $post_type ) );
     1583
    15801584        wp_cache_set( $cache_id, $child_count, 'bbpress_posts' );
     1585    } else {
     1586        $child_count = (int) $child_count;
    15811587    }
    15821588
     
    16261632
    16271633        $child_ids = (array) $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
     1634
    16281635        wp_cache_set( $cache_id, $child_ids, 'bbpress_posts' );
     1636    } else {
     1637        $child_ids = (array) $child_ids;
    16291638    }
    16301639
     
    16901699
    16911700        $child_ids = (array) $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
     1701
    16921702        wp_cache_set( $cache_id, $child_ids, 'bbpress_posts' );
     1703    } else {
     1704        $child_ids = (array) $child_ids;
    16931705    }
    16941706
Note: See TracChangeset for help on using the changeset viewer.