Make WordPress Core


Ignore:
Timestamp:
08/06/2008 08:31:54 PM (15 years ago)
Author:
markjaquith
Message:

Cast to array when using foreach(). Props santosj (and thanks for your perseverance!). fixes #2784

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r8570 r8572  
    422422    $wpdb->show_errors($show);
    423423
    424     foreach ( $options as $option ) {
     424    foreach ( (array) $options as $option ) {
    425425        // "When trying to design a foolproof system,
    426426        //  never underestimate the ingenuity of the fools :)" -- Dougal
     
    778778    debug_fwrite( $log, $content . "\n" );
    779779
    780     foreach ( $post_links_temp[0] as $link_test ) {
     780    foreach ( (array) $post_links_temp[0] as $link_test ) {
    781781        if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
    782782            $test = parse_url( $link_test );
     
    788788    }
    789789
    790     foreach ( $post_links as $url ) {
     790    foreach ( (array) $post_links as $url ) {
    791791        if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) {
    792792            if ( $headers = wp_get_http_headers( $url) ) {
     
    10081008    }
    10091009
    1010     foreach ( $qs as $k => $v ) {
     1010    foreach ( (array) $qs as $k => $v ) {
    10111011        if ( $v === false )
    10121012            unset( $qs[$k] );
     
    10321032function remove_query_arg( $key, $query=false ) {
    10331033    if ( is_array( $key ) ) { // removing multiple keys
    1034         foreach ( (array) $key as $k )
     1034        foreach ( $key as $k )
    10351035            $query = add_query_arg( $k, false, $query );
    10361036        return $query;
     
    10501050    global $wpdb;
    10511051
    1052     foreach ( $array as $k => $v ) {
     1052    foreach ( (array) $array as $k => $v ) {
    10531053        if ( is_array( $v ) ) {
    10541054            $array[$k] = add_magic_quotes( $v );
Note: See TracChangeset for help on using the changeset viewer.