Make WordPress Core

Changeset 8572


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

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

Location:
trunk/wp-includes
Files:
22 edited

Legend:

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

    r7701 r8572  
    2929        $this->role_objects = array();
    3030        $this->role_names =  array();
    31         foreach ($this->roles as $role => $data) {
     31        foreach ( (array) $this->roles as $role => $data) {
    3232            $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']);
    3333            $this->role_names[$role] = $this->roles[$role]['name'];
     
    208208
    209209    function set_role($role) {
    210         foreach($this->roles as $oldrole)
     210        foreach( (array) $this->roles as $oldrole)
    211211            unset($this->caps[$oldrole]);
    212212        if ( !empty($role) ) {
     
    266266        // Must have ALL requested caps
    267267        $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);
    268         foreach ($caps as $cap) {
     268        foreach ( (array) $caps as $cap) {
    269269            //echo "Checking cap $cap<br />";
    270270            if(empty($capabilities[$cap]) || !$capabilities[$cap])
  • trunk/wp-includes/category-template.php

    r8569 r8572  
    88    // TODO: consult hierarchy
    99    $cat_ids = get_all_category_ids();
    10     foreach ( $cat_ids as $cat_id ) {
     10    foreach ( (array) $cat_ids as $cat_id ) {
    1111        if ( $cat_id == $id )
    1212            continue;
     
    8585        $categories = array();
    8686
    87     foreach(array_keys($categories) as $key) {
     87    foreach( (array) array_keys($categories) as $key) {
    8888        _make_cat_compat($categories[$key]);
    8989    }
  • trunk/wp-includes/category.php

    r8090 r8572  
    4444    if ( 'link' == $args['type'] )
    4545        $taxonomy = 'link_category';
    46     $categories = get_terms($taxonomy, $args);
     46    $categories = (array) get_terms($taxonomy, $args);
    4747
    4848    foreach ( array_keys($categories) as $k )
  • trunk/wp-includes/classes.php

    r8510 r8572  
    9191            // Look for matches.
    9292            $request_match = $request;
    93             foreach ($rewrite as $match => $query) {
     93            foreach ( (array) $rewrite as $match => $query) {
    9494                // Don't try to match against AtomPub calls
    9595                if ( $req_uri == 'wp-app.php' )
     
    172172        }
    173173
    174         foreach ($this->private_query_vars as $var) {
     174        foreach ( (array) $this->private_query_vars as $var) {
    175175            if (isset($this->extra_query_vars[$var]))
    176176                $this->query_vars[$var] = $this->extra_query_vars[$var];
     
    243243    function build_query_string() {
    244244        $this->query_string = '';
    245         foreach (array_keys($this->query_vars) as $wpvar) {
     245        foreach ( (array) array_keys($this->query_vars) as $wpvar) {
    246246            if ( '' != $this->query_vars[$wpvar] ) {
    247247                $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
     
    262262        global $wp_query;
    263263        // Extract updated query vars back into global namespace.
    264         foreach ($wp_query->query_vars as $key => $value) {
     264        foreach ( (array) $wp_query->query_vars as $key => $value) {
    265265            $GLOBALS[$key] = $value;
    266266        }
     
    351351        if ( empty($code) ) {
    352352            $all_messages = array();
    353             foreach ( $this->errors as $code => $messages )
     353            foreach ( (array) $this->errors as $code => $messages )
    354354                $all_messages = array_merge($all_messages, $messages);
    355355
     
    528528        * then we got orphans, which should be displayed regardless
    529529        */
    530         if ( ( $max_depth == 0 ) && sizeof( $children_elements ) > 0 ) {
     530        if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {
    531531            $empty_array = array();
    532532            foreach ( $children_elements as $orphans )
     
    751751        $response = '';
    752752        if ( is_wp_error($data) ) {
    753             foreach ( $data->get_error_codes() as $code ) {
     753            foreach ( (array) $data->get_error_codes() as $code ) {
    754754                $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>";
    755755                if ( !$error_data = $data->get_error_data($code) )
     
    777777
    778778        $s = '';
    779         if ( (array) $supplemental ) {
     779        if ( is_array($supplemental) ) {
    780780            foreach ( $supplemental as $k => $v )
    781781                $s .= "<$k><![CDATA[$v]]></$k>";
     
    801801        header('Content-Type: text/xml');
    802802        echo "<?xml version='1.0' standalone='yes'?><wp_ajax>";
    803         foreach ( $this->responses as $response )
     803        foreach ( (array) $this->responses as $response )
    804804            echo $response;
    805805        echo '</wp_ajax>';
  • trunk/wp-includes/comment.php

    r8543 r8572  
    5353        $words = explode("\n", $mod_keys );
    5454
    55         foreach ($words as $word) {
     55        foreach ( (array) $words as $word) {
    5656            $word = trim($word);
    5757
     
    12361236    // We don't wanna ping first and second types, even if they have a valid <link/>
    12371237
    1238     foreach ( $post_links_temp[0] as $link_test ) :
     1238    foreach ( (array) $post_links_temp[0] as $link_test ) :
    12391239        if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
    12401240                && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
  • trunk/wp-includes/cron.php

    r8537 r8572  
    111111    foreach ( $crons as $timestamp => $cronhooks ) {
    112112        if ( $timestamp > time() ) break;
    113         foreach ( $cronhooks as $hook => $args ) {
     113        foreach ( (array) $cronhooks as $hook => $args ) {
    114114            if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
    115115                continue;
     
    169169    $new_cron = array();
    170170
    171     foreach ($cron as $timestamp => $hooks) {
    172         foreach ( $hooks as $hook => $args ) {
     171    foreach ( (array) $cron as $timestamp => $hooks) {
     172        foreach ( (array) $hooks as $hook => $args ) {
    173173            $key = md5(serialize($args['args']));
    174174            $new_cron[$timestamp][$hook][$key] = $args;
  • trunk/wp-includes/feed.php

    r8246 r8572  
    399399        return;
    400400
    401     foreach (get_post_custom() as $key => $val) {
     401    foreach ( (array) get_post_custom() as $key => $val) {
    402402        if ($key == 'enclosure') {
    403             foreach ((array)$val as $enc) {
     403            foreach ( (array) $val as $enc ) {
    404404                $enclosure = split("\n", $enc);
    405405                echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
     
    431431        return;
    432432
    433     foreach (get_post_custom() as $key => $val) {
     433    foreach ( (array) get_post_custom() as $key => $val ) {
    434434        if ($key == 'enclosure') {
    435             foreach ((array)$val as $enc) {
     435            foreach ( (array) $val as $enc ) {
    436436                $enclosure = split("\n", $enc);
    437437                echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
  • 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 );
  • trunk/wp-includes/general-template.php

    r8498 r8572  
    435435        if ( $arcresults ) {
    436436            $afterafter = $after;
    437             foreach ( $arcresults as $arcresult ) {
     437            foreach ( (array) $arcresults as $arcresult ) {
    438438                $url    = get_month_link($arcresult->year,  $arcresult->month);
    439439                $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
     
    456456        if ($arcresults) {
    457457            $afterafter = $after;
    458             foreach ($arcresults as $arcresult) {
     458            foreach ( (array) $arcresults as $arcresult) {
    459459                $url = get_year_link($arcresult->year);
    460460                $text = sprintf('%d', $arcresult->year);
     
    477477        if ( $arcresults ) {
    478478            $afterafter = $after;
    479             foreach ( $arcresults as $arcresult ) {
     479            foreach ( (array) $arcresults as $arcresult ) {
    480480                $url    = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    481481                $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
     
    501501        $afterafter = $after;
    502502        if ( $arcresults ) {
    503                 foreach ( $arcresults as $arcresult ) {
     503                foreach ( (array) $arcresults as $arcresult ) {
    504504                    if ( $arcresult->week != $arc_w_last ) {
    505505                        $arc_year = $arcresult->yr;
     
    529529        }
    530530        if ( $arcresults ) {
    531             foreach ( $arcresults as $arcresult ) {
     531            foreach ( (array) $arcresults as $arcresult ) {
    532532                if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
    533533                    $url  = get_permalink($arcresult);
     
    669669        AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    670670    if ( $dayswithposts ) {
    671         foreach ( $dayswithposts as $daywith ) {
     671        foreach ( (array) $dayswithposts as $daywith ) {
    672672            $daywithpost[] = $daywith[0];
    673673        }
     
    690690    );
    691691    if ( $ak_post_titles ) {
    692         foreach ( $ak_post_titles as $ak_post_title ) {
     692        foreach ( (array) $ak_post_titles as $ak_post_title ) {
    693693
    694694                $post_title = apply_filters( "the_title", $ak_post_title->post_title );
     
    757757    global $allowedtags;
    758758    $allowed = '';
    759     foreach ( $allowedtags as $tag => $attributes ) {
     759    foreach ( (array) $allowedtags as $tag => $attributes ) {
    760760        $allowed .= '<'.$tag;
    761761        if ( 0 < count($attributes) ) {
     
    10671067
    10681068    // Who knows what else people pass in $args
    1069     $total    = (int) $total;
     1069    $total  = (int) $total;
    10701070    if ( $total < 2 )
    10711071        return;
  • trunk/wp-includes/kses.php

    r8410 r8572  
    794794    $outarray = array ();
    795795
    796     foreach ($inarray as $inkey => $inval) {
     796    foreach ( (array) $inarray as $inkey => $inval) {
    797797        $outkey = strtolower($inkey);
    798798        $outarray[$outkey] = array ();
    799799
    800         foreach ($inval as $inkey2 => $inval2) {
     800        foreach ( (array) $inval as $inkey2 => $inval2) {
    801801            $outkey2 = strtolower($inkey2);
    802802            $outarray[$outkey][$outkey2] = $inval2;
  • trunk/wp-includes/locale.php

    r6589 r8572  
    191191
    192192        // Import global locale vars set during inclusion of $locale.php.
    193         foreach ( $this->locale_vars as $var ) {
     193        foreach ( (array) $this->locale_vars as $var ) {
    194194            if ( isset($GLOBALS[$var]) )
    195195                $this->$var = $GLOBALS[$var];
  • trunk/wp-includes/pluggable.php

    r8564 r8572  
    281281        if ( !empty( $tempheaders ) ) {
    282282            // Iterate through the raw headers
    283             foreach ( $tempheaders as $header ) {
     283            foreach ( (array) $tempheaders as $header ) {
    284284                if ( strpos($header, ':') === false )
    285285                    continue;
     
    364364    // Add any CC and BCC recipients
    365365    if ( !empty($cc) ) {
    366         foreach ($cc as $recipient) {
     366        foreach ( (array) $cc as $recipient ) {
    367367            $phpmailer->AddCc( trim($recipient) );
    368368        }
    369369    }
    370370    if ( !empty($bcc) ) {
    371         foreach ($bcc as $recipient) {
     371        foreach ( (array) $bcc as $recipient) {
    372372            $phpmailer->AddBcc( trim($recipient) );
    373373        }
     
    402402    // Set custom headers
    403403    if ( !empty( $headers ) ) {
    404         foreach ( $headers as $name => $content ) {
     404        foreach( (array) $headers as $name => $content ) {
    405405            $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
    406406        }
     
    790790    while($found) {
    791791        $found = false;
    792         foreach($strip as $val) {
     792        foreach( (array) $strip as $val ) {
    793793            while(strpos($location, $val) !== false) {
    794794                $found = true;
  • trunk/wp-includes/plugin.php

    r7999 r8572  
    9191        return false;
    9292
    93     foreach ( array_keys($wp_filter[$tag]) as $priority ) {
     93    foreach ( (array) array_keys($wp_filter[$tag]) as $priority ) {
    9494        if ( isset($wp_filter[$tag][$priority][$idx]) )
    9595            return $priority;
  • trunk/wp-includes/post-template.php

    r8547 r8572  
    256256    if ( $keys = get_post_custom_keys() ) {
    257257        echo "<ul class='post-meta'>\n";
    258         foreach ( $keys as $key ) {
     258        foreach ( (array) $keys as $key ) {
    259259            $keyt = trim($key);
    260260            if ( '_' == $keyt{0} )
  • trunk/wp-includes/post.php

    r8546 r8572  
    144144        return $kids;
    145145    } elseif ( $output == ARRAY_A ) {
    146         foreach ( $kids as $kid )
     146        foreach ( (array) $kids as $kid )
    147147            $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
    148148        return $weeuns;
    149149    } elseif ( $output == ARRAY_N ) {
    150         foreach ( $kids as $kid )
     150        foreach ( (array) $kids as $kid )
    151151            $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
    152152        return $babes;
     
    15801580
    15811581    // Update counts for the post's terms.
    1582     foreach ( get_object_taxonomies('post') as $taxonomy ) {
     1582    foreach ( (array) get_object_taxonomies('post') as $taxonomy ) {
    15831583        $terms = wp_get_object_terms($post_id, $taxonomy, 'fields=tt_ids');
    15841584        wp_update_term_count($terms, $taxonomy);
     
    18461846
    18471847        $trackback_urls = explode(',', $tb_list);
    1848         foreach($trackback_urls as $tb_url) {
     1848        foreach( (array) $trackback_urls as $tb_url) {
    18491849                $tb_url = trim($tb_url);
    18501850                trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
     
    19271927    $leaf_path  = sanitize_title(basename($page_paths));
    19281928    $page_paths = explode('/', $page_paths);
    1929     foreach($page_paths as $pathdir)
     1929    foreach( (array) $page_paths as $pathdir)
    19301930        $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    19311931
     
    19881988function &get_page_children($page_id, $pages) {
    19891989    $page_list = array();
    1990     foreach ( $pages as $page ) {
     1990    foreach ( (array) $pages as $page ) {
    19911991        if ( $page->post_parent == $page_id ) {
    19921992            $page_list[] = $page;
     
    20142014function get_page_hierarchy($posts, $parent = 0) {
    20152015    $result = array ( );
    2016     if ($posts) { foreach ($posts as $post) {
     2016    if ($posts) { foreach ( (array) $posts as $post) {
    20172017        if ($post->post_parent == $parent) {
    20182018            $result[$post->ID] = $post->post_name;
     
    30293029    }
    30303030
    3031     foreach ( array_keys($cache) as $post)
     3031    foreach ( (array) array_keys($cache) as $post)
    30323032        wp_cache_set($post, $cache[$post], 'post_meta');
    30333033
  • trunk/wp-includes/query.php

    r8555 r8572  
    215215    $page = (array) $page;
    216216
    217     if ( in_array( $page_obj->ID, $page ) )
     217    if ( in_array( $page_obj->ID, $page ) )
    218218        return true;
    219219    elseif ( in_array( $page_obj->post_title, $page ) )
     
    991991            $n = ($q['exact']) ? '' : '%';
    992992            $searchand = '';
    993             foreach((array)$q['search_terms'] as $term) {
     993            foreach( (array) $q['search_terms'] as $term) {
    994994                $term = addslashes_gpc($term);
    995995                $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))";
     
    10161016            $q['cat'] = '';
    10171017            $req_cats = array();
    1018             foreach ( $cat_array as $cat ) {
     1018            foreach ( (array) $cat_array as $cat ) {
    10191019                $cat = intval($cat);
    10201020                $req_cats[] = $cat;
  • trunk/wp-includes/rewrite.php

    r8510 r8572  
    158158            parse_str($query, $query_vars);
    159159            $query = array();
    160             foreach ( $query_vars as $key => $value ) {
     160            foreach ( (array) $query_vars as $key => $value ) {
    161161                if ( in_array($key, $wp->public_query_vars) )
    162162                    $query[$key] = $value;
     
    391391        preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
    392392        $tok_index = 1;
    393         foreach ($tokens[0] as $token) {
     393        foreach ( (array) $tokens[0] as $token) {
    394394            if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
    395395                $front = $front . 'date/';
     
    575575        //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
    576576        $feedregex2 = '';
    577         foreach ($this->feeds as $feed_name) {
     577        foreach ( (array) $this->feeds as $feed_name) {
    578578            $feedregex2 .= $feed_name . '|';
    579579        }
     
    590590        if ($endpoints) {
    591591            $ep_query_append = array ();
    592             foreach ($this->endpoints as $endpoint) {
     592            foreach ( (array) $this->endpoints as $endpoint) {
    593593                //match everything after the endpoint name, but allow for nothing to appear there
    594594                $epmatch = $endpoint[1] . '(/(.*))?/?$';
     
    689689            //do endpoints
    690690            if ($endpoints) {
    691                 foreach ($ep_query_append as $regex => $ep) {
     691                foreach ( (array) $ep_query_append as $regex => $ep) {
    692692                    //add the endpoints on if the mask fits
    693693                    if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
     
    746746
    747747                    //do endpoints for attachments
    748                     if (! empty($endpoint) ) { foreach ($ep_query_append as $regex => $ep) {
     748                    if ( !empty($endpoint) ) { foreach ( (array) $ep_query_append as $regex => $ep ) {
    749749                        if ($ep[0] & EP_ATTACHMENT) {
    750750                            $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
     
    894894
    895895        //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
    896         foreach ($this->non_wp_rules as $match => $query) {
     896        foreach ( (array) $this->non_wp_rules as $match => $query) {
    897897            // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    898898            $match = str_replace('.+?', '.+', $match);
     
    915915                "RewriteRule ^.*$ - [S=$num_rules]\n";
    916916
    917             foreach ($rewrite as $match => $query) {
     917            foreach ( (array) $rewrite as $match => $query) {
    918918                // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    919919                $match = str_replace('.+?', '.+', $match);
  • trunk/wp-includes/rss.php

    r8503 r8572  
    535535
    536536    // if RSS parsed successfully
    537     if ( $rss and !$rss->ERROR) {
     537    if ( $rss && !$rss->ERROR) {
    538538
    539539        // find Etag, and Last-Modified
    540         foreach($resp->headers as $h) {
     540        foreach( (array) $resp->headers as $h) {
    541541            // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
    542542            if (strpos($h, ": ")) {
     
    844844        }
    845845
    846         foreach ( $rss->items as $item ) {
     846        foreach ( (array) $rss->items as $item ) {
    847847            printf(
    848848                '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
     
    865865    if ( $rss ) {
    866866        $rss->items = array_slice($rss->items, 0, $num_items);
    867         foreach ($rss->items as $item ) {
     867        foreach ( (array) $rss->items as $item ) {
    868868            echo "<li>\n";
    869869            echo "<a href='$item[link]' title='$item[description]'>";
  • trunk/wp-includes/taxonomy.php

    r8433 r8572  
    5050
    5151    $taxonomies = array();
    52     foreach ( $wp_taxonomies as $taxonomy ) {
     52    foreach ( (array) $wp_taxonomies as $taxonomy ) {
    5353        if ( array_intersect($object, (array) $taxonomy->object_type) )
    5454            $taxonomies[] = $taxonomy->name;
     
    231231        $taxonomies = array($taxonomies);
    232232
    233     foreach ( $taxonomies as $taxonomy ) {
     233    foreach ( (array) $taxonomies as $taxonomy ) {
    234234        if ( ! is_taxonomy($taxonomy) )
    235235            return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
     
    426426    $children = $terms[$term];
    427427
    428     foreach ( $terms[$term] as $child ) {
     428    foreach ( (array) $terms[$term] as $child ) {
    429429        if ( isset($terms[$child]) )
    430430            $children = array_merge($children, get_term_children($child, $taxonomy));
     
    559559    }
    560560
    561     foreach ( $taxonomies as $taxonomy ) {
     561    foreach ( (array) $taxonomies as $taxonomy ) {
    562562        if ( ! is_taxonomy($taxonomy) )
    563563            return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
     
    627627        $interms = preg_split('/[\s,]+/',$include);
    628628        if ( count($interms) ) {
    629             foreach ( $interms as $interm ) {
     629            foreach ( (array) $interms as $interm ) {
    630630                if (empty($inclusions))
    631631                    $inclusions = ' AND ( t.term_id = ' . intval($interm) . ' ';
     
    644644        $exterms = preg_split('/[\s,]+/',$exclude);
    645645        if ( count($exterms) ) {
    646             foreach ( $exterms as $exterm ) {
     646            foreach ( (array) $exterms as $exterm ) {
    647647                if (empty($exclusions))
    648648                    $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
     
    722722
    723723    // Make sure we show empty categories that have children.
    724     if ( $hierarchical && $hide_empty ) {
     724    if ( $hierarchical && $hide_empty && is_array($terms) ) {
    725725        foreach ( $terms as $k => $term ) {
    726726            if ( ! $term->count ) {
    727727                $children = _get_term_children($term->term_id, $terms, $taxonomies[0]);
    728                 foreach ( $children as $child )
    729                     if ( $child->count )
    730                         continue 2;
     728                if( is_array($children) )
     729                    foreach ( $children as $child )
     730                        if ( $child->count )
     731                            continue 2;
    731732
    732733                // It really is empty
     
    825826        $do_object = true;
    826827
    827     foreach ( $fields as $field ) {
     828    foreach ( (array) $fields as $field ) {
    828829        if ( $do_object )
    829830            $term->$field = sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context);
     
    956957        $taxonomies = array($taxonomies);
    957958
    958     foreach ( $taxonomies as $taxonomy ) {
     959    foreach ( (array) $taxonomies as $taxonomy ) {
    959960        $terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
    960961        $in_terms = "'" . implode("', '", $terms) . "'";
     
    10831084        $taxonomies = array($taxonomies);
    10841085
    1085     foreach ( $taxonomies as $taxonomy ) {
     1086    foreach ( (array) $taxonomies as $taxonomy ) {
    10861087        if ( ! is_taxonomy($taxonomy) )
    10871088            return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
     
    13241325    $term_ids = array();
    13251326
    1326     foreach ($terms as $term) {
     1327    foreach ( (array) $terms as $term) {
    13271328        if ( !strlen(trim($term)) )
    13281329            continue;
     
    15881589
    15891590    if ( $do_deferred ) {
    1590         foreach ( array_keys($_deferred) as $tax ) {
     1591        foreach ( (array) array_keys($_deferred) as $tax ) {
    15911592            wp_update_term_count_now( $_deferred[$tax], $tax );
    15921593            unset( $_deferred[$tax] );
     
    16291630    } else {
    16301631        // Default count updater
    1631         foreach ($terms as $term) {
     1632        foreach ( (array) $terms as $term) {
    16321633            $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) );
    16331634            $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
     
    18221823 */
    18231824function update_term_cache($terms, $taxonomy = '') {
    1824     foreach ( $terms as $term ) {
     1825    foreach ( (array) $terms as $term ) {
    18251826        $term_taxonomy = $taxonomy;
    18261827        if ( empty($term_taxonomy) )
     
    18971898        return $empty_array;
    18981899
    1899     foreach ( $terms as $term ) {
     1900    foreach ( (array) $terms as $term ) {
    19001901        $use_id = false;
    19011902        if ( !is_object($term) ) {
     
    19571958    $term_items = array();
    19581959
    1959     foreach ( $terms as $key => $term ) {
     1960    foreach ( (array) $terms as $key => $term ) {
    19601961        $terms_by_id[$term->term_id] = & $terms[$key];
    19611962        $term_ids[$term->term_taxonomy_id] = $term->term_id;
     
    20072008    global $wpdb;
    20082009
    2009     foreach ( $terms as $term ) {
     2010    foreach ( (array) $terms as $term ) {
    20102011        $count = $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 = 'post' AND term_taxonomy_id = %d", $term ) );
    20112012        $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
  • trunk/wp-includes/user.php

    r8069 r8572  
    287287            $output .= "\t<option value='-1'>$show_option_none</option>\n";
    288288
    289         foreach ( $users as $user ) {
     289        foreach ( (array) $users as $user ) {
    290290            $user->ID = (int) $user->ID;
    291291            $_selected = $user->ID == $selected ? " selected='selected'" : '';
     
    312312
    313313    if ( $metavalues ) {
    314         foreach ( $metavalues as $meta ) {
     314        foreach ( (array) $metavalues as $meta ) {
    315315            $value = maybe_unserialize($meta->meta_value);
    316316            $user->{$meta->meta_key} = $value;
  • trunk/wp-includes/widgets.php

    r8567 r8572  
    209209    } else {
    210210        $index = sanitize_title($index);
    211         foreach ( $wp_registered_sidebars as $key => $value ) {
     211        foreach ( (array) $wp_registered_sidebars as $key => $value ) {
    212212            if ( sanitize_title($value['name']) == $index ) {
    213213                $index = $key;
     
    225225
    226226    $did_one = false;
    227     foreach ( $sidebars_widgets[$index] as $id ) {
     227    foreach ( (array) $sidebars_widgets[$index] as $id ) {
    228228        $params = array_merge(
    229229            array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
     
    275275    global $wp_registered_widgets, $wp_registered_sidebars;
    276276    $sidebars_widgets = get_option('sidebars_widgets');
    277     foreach ( $wp_registered_sidebars as $index => $sidebar ) {
     277    foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
    278278        if ( count($sidebars_widgets[$index]) ) {
    279             foreach ( $sidebars_widgets[$index] as $widget )
     279            foreach ( (array) $sidebars_widgets[$index] as $widget )
    280280                if ( array_key_exists($widget, $wp_registered_widgets) )
    281281                    return true;
     
    298298    switch ( $sidebars_widgets['array_version'] ) {
    299299        case 1 :
    300             foreach ( $sidebars_widgets as $index => $sidebar )
     300            foreach ( (array) $sidebars_widgets as $index => $sidebar )
    301301            if ( is_array($sidebar) )
    302             foreach ( $sidebar as $i => $name ) {
     302            foreach ( (array) $sidebar as $i => $name ) {
    303303                $id = strtolower($name);
    304304                if ( isset($wp_registered_widgets[$id]) ) {
     
    339339            if ( !empty( $sidebars ) ) {
    340340                // Move the known-good ones first
    341                 foreach ( $sidebars as $id ) {
     341                foreach ( (array) $sidebars as $id ) {
    342342                    if ( array_key_exists( $id, $sidebars_widgets ) ) {
    343343                        $_sidebars_widgets[$id] = $sidebars_widgets[$id];
     
    374374    $defaults = array();
    375375
    376     foreach ( $wp_registered_sidebars as $index => $sidebar )
     376    foreach ( (array) $wp_registered_sidebars as $index => $sidebar )
    377377        $defaults[$index] = array();
    378378
     
    636636            $this_sidebar = array();
    637637
    638         foreach ( $this_sidebar as $_widget_id ) {
     638        foreach ( (array) $this_sidebar as $_widget_id ) {
    639639            if ( 'wp_widget_text' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
    640640                $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
     
    684684
    685685    $id = false;
    686     foreach ( array_keys($options) as $o ) {
     686    foreach ( (array) array_keys($options) as $o ) {
    687687        // Old widgets can have null values for some reason
    688688        if ( !isset($options[$o]['title']) || !isset($options[$o]['text']) )
     
    730730<script type='text/javascript'>
    731731/* <![CDATA[ */
    732     var dropdown = document.getElementById("cat");
    733     function onCatChange() {
     732    var dropdown = document.getElementById("cat");
     733    function onCatChange() {
    734734        if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    735735            location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
    736736        }
    737     }
    738     dropdown.onchange = onCatChange;
     737    }
     738    dropdown.onchange = onCatChange;
    739739/* ]]> */
    740740</script>
     
    778778            $this_sidebar = array();
    779779
    780         foreach ( $this_sidebar as $_widget_id ) {
     780        foreach ( (array) $this_sidebar as $_widget_id ) {
    781781            if ( 'wp_widget_categories' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
    782782                $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
     
    853853
    854854    $id = false;
    855     foreach ( array_keys($options) as $o ) {
     855    foreach ( (array) array_keys($options) as $o ) {
    856856        // Old widgets can have null values for some reason
    857857        if ( !isset($options[$o]['title']) )
     
    987987            <?php echo $before_title . $title . $after_title; ?>
    988988            <ul id="recentcomments"><?php
    989             if ( $comments ) : foreach ($comments as $comment) :
     989            if ( $comments ) : foreach ( (array) $comments as $comment) :
    990990            echo  '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
    991991            endforeach; endif;?></ul>
     
    11181118        $rss->items = array_slice($rss->items, 0, $items);
    11191119        echo '<ul>';
    1120         foreach ($rss->items as $item ) {
     1120        foreach ( (array) $rss->items as $item ) {
    11211121            while ( strstr($item['link'], 'http') != $item['link'] )
    11221122                $item['link'] = substr($item['link'], 1);
     
    11851185
    11861186    $urls = array();
    1187     foreach ( $options as $option )
     1187    foreach ( (array) $options as $option )
    11881188        if ( isset($option['url']) )
    11891189            $urls[$option['url']] = true;
     
    11981198            $this_sidebar = array();
    11991199
    1200         foreach ( $this_sidebar as $_widget_id ) {
     1200        foreach ( (array) $this_sidebar as $_widget_id ) {
    12011201            if ( 'wp_widget_rss' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
    12021202                $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
     
    13431343
    13441344    $id = false;
    1345     foreach ( array_keys($options) as $o ) {
     1345    foreach ( (array) array_keys($options) as $o ) {
    13461346        // Old widgets can have null values for some reason
    13471347        if ( !isset($options[$o]['url']) || !isset($options[$o]['title']) || !isset($options[$o]['items']) )
  • trunk/wp-includes/wp-db.php

    r8311 r8572  
    379379        $this->prefix = $prefix;
    380380
    381         foreach ( $this->tables as $table )
     381        foreach ( (array) $this->tables as $table )
    382382            $this->$table = $this->prefix . $table;
    383383
     
    678678        $data = add_magic_quotes($data);
    679679        $bits = $wheres = array();
    680         foreach ( array_keys($data) as $k )
     680        foreach ( (array) array_keys($data) as $k )
    681681            $bits[] = "`$k` = '$data[$k]'";
    682682
     
    806806            if ( $this->last_result ) {
    807807                $i = 0;
    808                 foreach( $this->last_result as $row ) {
     808                foreach( (array) $this->last_result as $row ) {
    809809                    if ( $output == ARRAY_N ) {
    810810                        // ...integer-keyed row arrays
     
    834834            if ( $col_offset == -1 ) {
    835835                $i = 0;
    836                 foreach($this->col_info as $col ) {
     836                foreach( (array) $this->col_info as $col ) {
    837837                    $new_array[$i] = $col->{$info_type};
    838838                    $i++;
     
    942942        $caller = '';
    943943
    944         foreach ( $bt as $trace ) {
     944        foreach ( (array) $bt as $trace ) {
    945945            if ( @$trace['class'] == __CLASS__ )
    946946                continue;
Note: See TracChangeset for help on using the changeset viewer.