Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/19/2017 03:25:37 AM (9 years ago)
Author:
johnjamesjacoby
Message:

in_array(): be strict whenever possible.

Use wp_parse_id_list() on certain array values to ensure proper results.

File:
1 edited

Legend:

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

    r6401 r6415  
    296296
    297297        // Check a whitelist of possible topic status ID's
    298         } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( $topic_statuses ) ) ) {
     298        } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( $topic_statuses ), true ) ) {
    299299                $topic_status = sanitize_key( $_POST['bbp_topic_status'] );
    300300
    … …  
    615615
    616616        // Check a whitelist of possible topic status ID's
    617         } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( $topic_statuses ) ) ) {
     617        } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( $topic_statuses ), true ) ) {
    618618                $topic_status = sanitize_key( $_POST['bbp_topic_status'] );
    619619
    … …  
    11221122
    11231123        // Make sure we're not walking twice
    1124         if ( ! in_array( $new_forum_id, $old_forum_ancestors ) ) {
     1124        if ( ! in_array( $new_forum_id, $old_forum_ancestors, true ) ) {
    11251125
    11261126                // Get topic ancestors
    … …  
    15331533
    15341534        // Invalid split option
    1535         if ( empty( $split_option ) || ! in_array( $split_option, array( 'existing', 'reply' ) ) ) {
     1535        if ( empty( $split_option ) || ! in_array( $split_option, array( 'existing', 'reply' ), true ) ) {
    15361536                bbp_add_error( 'bbp_split_topic_option', __( '<strong>ERROR</strong>: You need to choose a valid split option.', 'bbpress' ) );
    15371537
    … …  
    17251725
    17261726                        // Not a reply to a reply that moved over
    1727                         if ( ! in_array( $reply_to, $reply_ids ) ) {
     1727                        if ( ! in_array( $reply_to, $reply_ids, true ) ) {
    17281728                                bbp_update_reply_to( $reply->ID, 0 );
    17291729                        }
    … …  
    18521852
    18531853        // Bail if actions aren't meant for this function
    1854         if ( ! in_array( $action, $possible_actions ) ) {
     1854        if ( ! in_array( $action, $possible_actions, true ) ) {
    18551855                return;
    18561856        }
    … …  
    20872087        $stickies = ( empty( $stickies ) || ! is_array( $stickies ) )
    20882088                ? array()
    2089                 : $stickies;
     2089                : wp_parse_id_list( $stickies );
    20902090
    20912091        // Filter and return
    … …  
    21102110        $stickies = ( empty( $stickies ) || ! is_array( $stickies ) )
    21112111                ? array()
    2112                 : $stickies;
     2112                : wp_parse_id_list( $stickies );
    21132113
    21142114        // Filter and return
    … …  
    36543654        if ( empty( $stickies ) ) {
    36553655                $success = true;
    3656         } elseif ( ! in_array( $topic_id, $stickies ) ) {
     3656        } elseif ( ! in_array( $topic_id, $stickies, true ) ) {
    36573657                $success = true;
    36583658        } elseif ( false === $offset ) {
Note: See TracChangeset for help on using the changeset viewer.