Make WordPress Core

Ticket #2784: arraytypecast.patch

File arraytypecast.patch, 43.0 KB (added by darkdragon, 18 years ago)

Corrected version based off of r6563 for adding array type casting to foreach loops in wp-includes folder

  • capabilities.php

     
    2828
    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'];
    3434                }
     
    207207        }
    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) ) {
    213213                        $this->caps[$role] = true;
     
    265265                $caps = call_user_func_array('map_meta_cap', $args);
    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])
    271271                                return false;
  • category-template.php

     
    77        $chain = '';
    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;
    1313
     
    8181        else
    8282                $categories = array();
    8383
    84         foreach(array_keys($categories) as $key) {
     84        foreach( (array) array_keys($categories) as $key) {
    8585                _make_cat_compat($categories[$key]);
    8686        }
    8787
  • category.php

     
    1616        $taxonomy = 'category';
    1717        if ( 'link' == $args['type'] )
    1818                $taxonomy = 'link_category';
    19         $categories = get_terms($taxonomy, $args);
     19        $categories = (array) get_terms($taxonomy, $args);
    2020
    2121        foreach ( array_keys($categories) as $k )
    2222                _make_cat_compat($categories[$k]);
  • classes.php

     
    8989
    9090                        // Look for matches.
    9191                        $request_match = $request;
    92                         foreach ($rewrite as $match => $query) {
     92                        foreach ( (array) $rewrite as $match => $query) {
    9393                                // If the requesting file is the anchor of the match, prepend it
    9494                                // to the path info.
    9595                                if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) {
     
    157157                                $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar];
    158158                }
    159159
    160                 foreach ($this->private_query_vars as $var) {
     160                foreach ( (array) $this->private_query_vars as $var) {
    161161                        if (isset($this->extra_query_vars[$var]))
    162162                                $this->query_vars[$var] = $this->extra_query_vars[$var];
    163163                        elseif (isset($GLOBALS[$var]) && '' != $GLOBALS[$var])
     
    228228
    229229        function build_query_string() {
    230230                $this->query_string = '';
    231                 foreach (array_keys($this->query_vars) as $wpvar) {
     231                foreach ( (array) array_keys($this->query_vars) as $wpvar) {
    232232                        if ( '' != $this->query_vars[$wpvar] ) {
    233233                                $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
    234234                                if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars.
     
    247247        function register_globals() {
    248248                global $wp_query;
    249249                // Extract updated query vars back into global namespace.
    250                 foreach ($wp_query->query_vars as $key => $value) {
     250                foreach ( (array) $wp_query->query_vars as $key => $value) {
    251251                        $GLOBALS[$key] = $value;
    252252                }
    253253
     
    336336                // Return all messages if no code specified.
    337337                if ( empty($code) ) {
    338338                        $all_messages = array();
    339                         foreach ( $this->errors as $code => $messages )
     339                        foreach ( (array) $this->errors as $code => $messages )
    340340                                $all_messages = array_merge($all_messages, $messages);
    341341
    342342                        return $all_messages;
     
    517517                * if we are displaying all levels, and remaining children_elements is not empty,
    518518                * then we got orphans, which should be displayed regardless
    519519                */
    520                 if ( ( $max_depth == 0 ) && sizeof( $children_elements ) > 0 ) {
     520                if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {
    521521                        $empty_array = array();
    522522                        foreach ( $children_elements as $orphan_e )
    523523                                $output = $this->display_element( $orphan_e, $empty_array, 1, 0, $args, $output );
     
    749749
    750750                $response = '';
    751751                if ( is_wp_error($data) ) {
    752                         foreach ( $data->get_error_codes() as $code ) {
     752                        foreach ( (array) $data->get_error_codes() as $code ) {
    753753                                $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>";
    754754                                if ( !$error_data = $data->get_error_data($code) )
    755755                                        continue;
     
    775775                }
    776776
    777777                $s = '';
    778                 if ( (array) $supplemental )
     778                if ( is_array($supplemental) )
    779779                        foreach ( $supplemental as $k => $v )
    780780                                $s .= "<$k><![CDATA[$v]]></$k>";
    781781
     
    797797        function send() {
    798798                header('Content-Type: text/xml');
    799799                echo "<?xml version='1.0' standalone='yes'?><wp_ajax>";
    800                 foreach ( $this->responses as $response )
     800                foreach ( (array) $this->responses as $response )
    801801                        echo $response;
    802802                echo '</wp_ajax>';
    803803                die();
  • comment-template.php

     
    105105 */
    106106function get_comment_author_link() {
    107107        /** @todo Only call these functions when they are needed. Include in if... else blocks */
    108         $url    = get_comment_author_url();
     108        $url    = get_comment_author_url();
    109109        $author = get_comment_author();
    110110
    111111        if ( empty( $url ) || 'http://' == $url )
     
    763763        echo '</a>';
    764764}
    765765
    766 ?>
    767  No newline at end of file
     766?>
  • comment.php

     
    3535        if ( !empty($mod_keys) ) {
    3636                $words = explode("\n", $mod_keys );
    3737
    38                 foreach ($words as $word) {
     38                foreach ( (array) $words as $word) {
    3939                        $word = trim($word);
    4040
    4141                        // Skip empty lines
     
    11131113        // http://dummy-weblog.org/post.php
    11141114        // We don't wanna ping first and second types, even if they have a valid <link/>
    11151115
    1116         foreach ( $post_links_temp[0] as $link_test ) :
     1116        foreach ( (array) $post_links_temp[0] as $link_test ) :
    11171117                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
    11181118                                && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
    11191119                        $test = parse_url($link_test);
  • cron.php

     
    121121        $schedules = wp_get_schedules();
    122122        foreach ( $crons as $timestamp => $cronhooks ) {
    123123                if ( $timestamp > time() ) break;
    124                 foreach ( $cronhooks as $hook => $args ) {
     124                foreach ( (array) $cronhooks as $hook => $args ) {
    125125                        if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
    126126                                continue;
    127127                        spawn_cron();
     
    178178
    179179        $new_cron = array();
    180180
    181         foreach ($cron as $timestamp => $hooks) {
    182                 foreach ( $hooks as $hook => $args ) {
     181        foreach ( (array) $cron as $timestamp => $hooks) {
     182                foreach ( (array) $hooks as $hook => $args ) {
    183183                        $key = md5(serialize($args['args']));
    184184                        $new_cron[$timestamp][$hook][$key] = $args;
    185185                }
  • feed.php

     
    148148        if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
    149149                return;
    150150
    151         foreach (get_post_custom() as $key => $val) {
     151        foreach ( (array) get_post_custom() as $key => $val) {
    152152                if ($key == 'enclosure') {
    153                         foreach ((array)$val as $enc) {
     153                        foreach ( (array) $val as $enc ) {
    154154                                $enclosure = split("\n", $enc);
    155155                                echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
    156156                        }
     
    163163        if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
    164164                return;
    165165
    166         foreach (get_post_custom() as $key => $val) {
     166        foreach ( (array) get_post_custom() as $key => $val ) {
    167167                if ($key == 'enclosure') {
    168                         foreach ((array)$val as $enc) {
     168                        foreach ( (array) $val as $enc ) {
    169169                                $enclosure = split("\n", $enc);
    170170                                echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
    171171                        }
  • formatting.php

     
    678678
    679679function convert_smilies($text) {
    680680        global $wp_smiliessearch, $wp_smiliesreplace;
    681     $output = '';
     681        $output = '';
    682682        if ( get_option('use_smilies') && !empty($wp_smiliessearch) && !empty($wp_smiliesreplace) ) {
    683683                // HTML loop taken from texturize function, could possible be consolidated
    684684                $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
  • functions.php

     
    251251                $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
    252252        $wpdb->show_errors($show);
    253253
    254         foreach ( $options as $option ) {
     254        foreach ( (array) $options as $option ) {
    255255                // "When trying to design a foolproof system,
    256256                //  never underestimate the ingenuity of the fools :)" -- Dougal
    257257                if ( in_array( $option->option_name, array( 'siteurl', 'home', 'category_base' ) ) )
     
    404404function gzip_compression() {
    405405        if ( !get_option( 'gzipcompression' ) || ini_get( 'zlib.output_compression' ) == 'On' || ini_get( 'zlib.output_compression_level' ) > 0  || ini_get( 'output_handler' ) == 'ob_gzhandler' || !extension_loaded( 'zlib' ) )
    406406                return false;
     407        ob_clean_flush();
    407408        ob_start( 'ob_gzhandler' );
    408409}
    409410
     
    505506        debug_fwrite( $log, 'Post contents:' );
    506507        debug_fwrite( $log, $content . "\n" );
    507508
    508         foreach ( $post_links_temp[0] as $link_test ) {
     509        foreach ( (array) $post_links_temp[0] as $link_test ) {
    509510                if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
    510511                        $test = parse_url( $link_test );
    511512                        if ( isset( $test['query'] ) )
     
    515516                }
    516517        }
    517518
    518         foreach ( $post_links as $url ) {
     519        foreach ( (array) $post_links as $url ) {
    519520                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 . '%' ) ) ) {
    520521                        if ( $headers = wp_get_http_headers( $url) ) {
    521522                                $len = (int) $headers['content-length'];
     
    686687                $qs[func_get_arg( 0 )] = func_get_arg( 1 );
    687688        }
    688689
    689         foreach ( $qs as $k => $v ) {
     690        foreach ( (array) $qs as $k => $v ) {
    690691                if ( $v === false )
    691692                        unset( $qs[$k] );
    692693        }
     
    712713
    713714function remove_query_arg( $key, $query=FALSE ) {
    714715        if ( is_array( $key ) ) { // removing multiple keys
    715                 foreach ( (array) $key as $k )
     716                foreach ( $key as $k )
    716717                        $query = add_query_arg( $k, FALSE, $query );
    717718                return $query;
    718719        }
     
    723724function add_magic_quotes( $array ) {
    724725        global $wpdb;
    725726
    726         foreach ( $array as $k => $v ) {
     727        foreach ( (array) $array as $k => $v ) {
    727728                if ( is_array( $v ) ) {
    728729                        $array[$k] = add_magic_quotes( $v );
    729730                } else {
  • general-template.php

     
    407407                }
    408408                if ( $arcresults ) {
    409409                        $afterafter = $after;
    410                         foreach ( $arcresults as $arcresult ) {
     410                        foreach ( (array) $arcresults as $arcresult ) {
    411411                                $url    = get_month_link($arcresult->year,      $arcresult->month);
    412412                                $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
    413413                                if ( $show_post_count )
     
    428428                }
    429429                if ($arcresults) {
    430430                        $afterafter = $after;
    431                         foreach ($arcresults as $arcresult) {
     431                        foreach ( (array) $arcresults as $arcresult) {
    432432                                $url = get_year_link($arcresult->year);
    433433                                $text = sprintf('%d', $arcresult->year);
    434434                                if ($show_post_count)
     
    449449                }
    450450                if ( $arcresults ) {
    451451                        $afterafter = $after;
    452                         foreach ( $arcresults as $arcresult ) {
     452                        foreach ( (array) $arcresults as $arcresult ) {
    453453                                $url    = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    454454                                $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    455455                                $text = mysql2date($archive_day_date_format, $date);
     
    473473                $arc_w_last = '';
    474474                $afterafter = $after;
    475475                if ( $arcresults ) {
    476                                 foreach ( $arcresults as $arcresult ) {
     476                                foreach ( (array) $arcresults as $arcresult ) {
    477477                                        if ( $arcresult->week != $arc_w_last ) {
    478478                                                $arc_year = $arcresult->yr;
    479479                                                $arc_w_last = $arcresult->week;
     
    501501                        $arcresults = $cache[ $key ];
    502502                }
    503503                if ( $arcresults ) {
    504                         foreach ( $arcresults as $arcresult ) {
     504                        foreach ( (array) $arcresults as $arcresult ) {
    505505                                if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
    506506                                        $url  = get_permalink($arcresult);
    507507                                        $arc_title = $arcresult->post_title;
     
    641641                AND post_type = 'post' AND post_status = 'publish'
    642642                AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    643643        if ( $dayswithposts ) {
    644                 foreach ( $dayswithposts as $daywith ) {
     644                foreach ( (array) $dayswithposts as $daywith ) {
    645645                        $daywithpost[] = $daywith[0];
    646646                }
    647647        } else {
     
    662662                ."AND post_type = 'post' AND post_status = 'publish'"
    663663        );
    664664        if ( $ak_post_titles ) {
    665                 foreach ( $ak_post_titles as $ak_post_title ) {
     665                foreach ( (array) $ak_post_titles as $ak_post_title ) {
    666666
    667667                                $post_title = apply_filters( "the_title", $ak_post_title->post_title );
    668668                                $post_title = str_replace('"', '&quot;', wptexturize( $post_title ));
     
    729729function allowed_tags() {
    730730        global $allowedtags;
    731731        $allowed = '';
    732         foreach ( $allowedtags as $tag => $attributes ) {
     732        foreach ( (array) $allowedtags as $tag => $attributes ) {
    733733                $allowed .= '<'.$tag;
    734734                if ( 0 < count($attributes) ) {
    735735                        foreach ( $attributes as $attribute => $limits ) {
     
    926926        <div id='editor-toolbar' style='display:none;'>
    927927                <div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors("<?php echo $id; ?>")' /></div>
    928928                <a id='edButtonHTML' class='' onclick='switchEditors("<?php echo $id; ?>")'><?php _e('HTML'); ?></a>
    929         <a id='edButtonPreview' class='active'><?php _e('Visual'); ?></a>
    930         <div id="media-buttons">
    931         <?php _e('Add media:'); ?>
    932         <?php do_action( 'media_buttons'); ?>
    933         </div>
     929                <a id='edButtonPreview' class='active'><?php _e('Visual'); ?></a>
     930                <div id="media-buttons">
     931                <?php _e('Add media:'); ?>
     932                <?php do_action( 'media_buttons'); ?>
     933                </div>
    934934        </div>
    935935        <script type="text/javascript">
    936936        // <![CDATA[
     
    10491049        extract($args, EXTR_SKIP);
    10501050
    10511051        // Who knows what else people pass in $args
    1052         $total    = (int) $total;
     1052        $total  = (int) $total;
    10531053        if ( $total < 2 )
    10541054                return;
    10551055        $current  = (int) $current;
  • kses.php

     
    586586{
    587587        $outarray = array ();
    588588
    589         foreach ($inarray as $inkey => $inval) {
     589        foreach ( (array) $inarray as $inkey => $inval) {
    590590                $outkey = strtolower($inkey);
    591591                $outarray[$outkey] = array ();
    592592
    593                 foreach ($inval as $inkey2 => $inval2) {
     593                foreach ( (array) $inval as $inkey2 => $inval2) {
    594594                        $outkey2 = strtolower($inkey2);
    595595                        $outarray[$outkey][$outkey2] = $inval2;
    596596                } # foreach $inval
     
    641641        $string2 = strtolower($string2);
    642642
    643643        $allowed = false;
    644         foreach ($allowed_protocols as $one_protocol)
     644        foreach ( (array) $allowed_protocols as $one_protocol)
    645645                if (strtolower($one_protocol) == $string2) {
    646646                        $allowed = true;
    647647                        break;
  • locale.php

     
    100100                $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
    101101
    102102                // Import global locale vars set during inclusion of $locale.php.
    103                 foreach ( $this->locale_vars as $var ) {
     103                foreach ( (array) $this->locale_vars as $var ) {
    104104                        if ( isset($GLOBALS[$var]) )
    105105                                $this->$var = $GLOBALS[$var];
    106106                }
  • pluggable.php

     
    451451
    452452                $auth_cookie = '';
    453453                $cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
    454                 foreach ( $cookie as $tasty ) {
     454                foreach ( (array) $cookie as $tasty ) {
    455455                        if ( false !== strpos($tasty, AUTH_COOKIE) )
    456456                                $auth_cookie = substr(strstr($tasty, '='), 1);
    457457                }
     
    506506        $found = true;
    507507        while($found) {
    508508                $found = false;
    509                 foreach($strip as $val) {
     509                foreach( (array) $strip as $val) {
    510510                        while(strpos($location, $val) !== false) {
    511511                                $found = true;
    512512                                $location = str_replace($val, '', $location);
  • plugin.php

     
    9090        if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) )
    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;
    9696        }
  • post-template.php

     
    250250function the_meta() {
    251251        if ( $keys = get_post_custom_keys() ) {
    252252                echo "<ul class='post-meta'>\n";
    253                 foreach ( $keys as $key ) {
     253                foreach ( (array) $keys as $key ) {
    254254                        $keyt = trim($key);
    255255                        if ( '_' == $keyt{0} )
    256256                                continue;
  • post.php

     
    100100        if ( $output == OBJECT ) {
    101101                return $kids;
    102102        } elseif ( $output == ARRAY_A ) {
    103                 foreach ( $kids as $kid )
     103                foreach ( (array) $kids as $kid )
    104104                        $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
    105105                return $weeuns;
    106106        } elseif ( $output == ARRAY_N ) {
    107                 foreach ( $kids as $kid )
     107                foreach ( (array) $kids as $kid )
    108108                        $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
    109109                return $babes;
    110110        } else {
     
    12031203        wp_transition_post_status('publish', $old_status, $post);
    12041204
    12051205        // Update counts for the post's terms.
    1206         foreach ( get_object_taxonomies('post') as $taxonomy ) {
     1206        foreach ( (array) get_object_taxonomies('post') as $taxonomy ) {
    12071207                $terms = wp_get_object_terms($post_id, $taxonomy, 'fields=tt_ids');
    12081208                wp_update_term_count($terms, $taxonomy);
    12091209        }
     
    14011401                }
    14021402
    14031403                $trackback_urls = explode(',', $tb_list);
    1404                 foreach($trackback_urls as $tb_url) {
     1404                foreach( (array) $trackback_urls as $tb_url) {
    14051405                                $tb_url = trim($tb_url);
    14061406                                trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
    14071407                }
     
    14821482        $page_paths = '/' . trim($page_path, '/');
    14831483        $leaf_path  = sanitize_title(basename($page_paths));
    14841484        $page_paths = explode('/', $page_paths);
    1485         foreach($page_paths as $pathdir)
     1485        foreach( (array) $page_paths as $pathdir)
    14861486                $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    14871487
    14881488        $pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = 'page' OR post_type = 'attachment')", $leaf_path ));
     
    15431543 */
    15441544function &get_page_children($page_id, $pages) {
    15451545        $page_list = array();
    1546         foreach ( $pages as $page ) {
     1546        foreach ( (array) $pages as $page ) {
    15471547                if ( $page->post_parent == $page_id ) {
    15481548                        $page_list[] = $page;
    15491549                        if ( $children = get_page_children($page->ID, $pages) )
     
    15691569 */
    15701570function get_page_hierarchy($posts, $parent = 0) {
    15711571        $result = array ( );
    1572         if ($posts) { foreach ($posts as $post) {
     1572        if ($posts) { foreach ( (array) $posts as $post) {
    15731573                if ($post->post_parent == $parent) {
    15741574                        $result[$post->ID] = $post->post_name;
    15751575                        $children = get_page_hierarchy($posts, $post->ID);
     
    25132513                        $cache[$id] = array();
    25142514        }
    25152515
    2516         foreach ( array_keys($cache) as $post)
     2516        foreach ( (array) array_keys($cache) as $post)
    25172517                wp_cache_set($post, $cache[$post], 'post_meta');
    25182518
    25192519        return $cache;
  • query.php

     
    153153        $page_obj = $wp_query->get_queried_object();
    154154
    155155        $page = (array) $page;
    156    
    157     if ( in_array( $page_obj->ID, $page ) )
     156       
     157        if ( in_array( $page_obj->ID, $page ) )
    158158                return true;
    159159        elseif ( in_array( $page_obj->post_title, $page ) )
    160160                return true;
     
    895895                        }
    896896                        $n = ($q['exact']) ? '' : '%';
    897897                        $searchand = '';
    898                         foreach((array)$q['search_terms'] as $term) {
     898                        foreach( (array) $q['search_terms'] as $term) {
    899899                                $term = addslashes_gpc($term);
    900900                                $search .= "{$searchand}((post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}'))";
    901901                                $searchand = ' AND ';
     
    918918                        $q['cat'] = ''.urldecode($q['cat']).'';
    919919                        $q['cat'] = addslashes_gpc($q['cat']);
    920920                        $cat_array = preg_split('/[,\s]+/', $q['cat']);
    921                         foreach ( $cat_array as $cat ) {
     921                        foreach ( (array) $cat_array as $cat ) {
    922922                                $cat = intval($cat);
    923923                                $in = ($cat > 0);
    924924                                $cat = abs($cat);
  • rewrite.php

     
    140140                        global $wp;
    141141                        parse_str($query, $query_vars);
    142142                        $query = array();
    143                         foreach ( $query_vars as $key => $value ) {
     143                        foreach ( (array) $query_vars as $key => $value ) {
    144144                                if ( in_array($key, $wp->public_query_vars) )
    145145                                        $query[$key] = $value;
    146146                        }
     
    293293                        return array( array(), array() );
    294294       
    295295
    296                 foreach ($posts as $id => $post) {
     296                foreach ( $posts as $id => $post) {
    297297                        // URL => page name
    298298                        $uri = get_page_uri($id);
    299299                        $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id ));
     
    372372                $front = $this->front;
    373373                preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
    374374                $tok_index = 1;
    375                 foreach ($tokens[0] as $token) {
     375                foreach ( (array) $tokens[0] as $token) {
    376376                        if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
    377377                                $front = $front . 'date/';
    378378                                break;
     
    552552        function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
    553553                //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
    554554                $feedregex2 = '';
    555                 foreach ($this->feeds as $feed_name) {
     555                foreach ( (array) $this->feeds as $feed_name) {
    556556                        $feedregex2 .= $feed_name . '|';
    557557                }
    558558                $feedregex2 = '(' . trim($feedregex2, '|') .  ')/?$';
     
    567567                //build up an array of endpoint regexes to append => queries to append
    568568                if ($endpoints) {
    569569                        $ep_query_append = array ();
    570                         foreach ($this->endpoints as $endpoint) {
     570                        foreach ( (array) $this->endpoints as $endpoint) {
    571571                                //match everything after the endpoint name, but allow for nothing to appear there
    572572                                $epmatch = $endpoint[1] . '(/(.*))?/?$';
    573573                                //this will be appended on to the rest of the query for each dir
     
    664664
    665665                        //do endpoints
    666666                        if ($endpoints) {
    667                                 foreach ($ep_query_append as $regex => $ep) {
     667                                foreach ( (array) $ep_query_append as $regex => $ep) {
    668668                                        //add the endpoints on if the mask fits
    669669                                        if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
    670670                                                $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
     
    721721                                        $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
    722722
    723723                                        //do endpoints for attachments
    724                                         if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
     724                                        if ($endpoint) { foreach ( (array) $ep_query_append as $regex => $ep) {
    725725                                                if ($ep[0] & EP_ATTACHMENT) {
    726726                                                        $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
    727727                                                        $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
     
    865865                $rules .= "RewriteBase $home_root\n";
    866866
    867867                //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
    868                 foreach ($this->non_wp_rules as $match => $query) {
     868                foreach ( (array) $this->non_wp_rules as $match => $query) {
    869869                        // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    870870                        $match = str_replace('.+?', '.+', $match);
    871871
     
    886886                                "RewriteCond %{REQUEST_FILENAME} -d\n" .
    887887                                "RewriteRule ^.*$ - [S=$num_rules]\n";
    888888
    889                         foreach ($rewrite as $match => $query) {
     889                        foreach ( (array) $rewrite as $match => $query) {
    890890                                // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    891891                                $match = str_replace('.+?', '.+', $match);
    892892
  • rss.php

     
    22do_action('load_feed_engine');
    33
    44/*
    5  * Project:    MagpieRSS: a simple RSS integration tool
    6  * File:        A compiled file for RSS syndication
    7  * Author:      Kellan Elliott-McCrea <kellan@protest.net>
     5 * Project:      MagpieRSS: a simple RSS integration tool
     6 * File:                A compiled file for RSS syndication
     7 * Author:        Kellan Elliott-McCrea <kellan@protest.net>
    88 * Version:             0.51
    99 * License:             GPL
    1010 */
     
    525525        $rss = new MagpieRSS( $resp->results );
    526526
    527527        // if RSS parsed successfully
    528         if ( $rss and !$rss->ERROR) {
     528        if ( $rss && !$rss->ERROR) {
    529529
    530530                // find Etag, and Last-Modified
    531                 foreach($resp->headers as $h) {
     531                foreach( (array) $resp->headers as $h) {
    532532                        // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
    533533                        if (strpos($h, ": ")) {
    534534                                list($field, $val) = explode(": ", $h, 2);
     
    833833                        $rss->items = array_slice( $rss->items, 0, $num_items );
    834834                }
    835835
    836                 foreach ( $rss->items as $item ) {
     836                foreach ( (array) $rss->items as $item ) {
    837837                        printf(
    838838                                '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
    839839                                clean_url( $item['link'] ),
     
    854854        $rss = fetch_rss($url);
    855855        if ( $rss ) {
    856856                $rss->items = array_slice($rss->items, 0, $num_items);
    857                 foreach ($rss->items as $item ) {
     857                foreach ( (array) $rss->items as $item ) {
    858858                        echo "<li>\n";
    859859                        echo "<a href='$item[link]' title='$item[description]'>";
    860860                        echo htmlentities($item['title']);
  • script-loader.php

     
    164164
    165165                $to_print = apply_filters( 'print_scripts_array', array_keys($this->to_print) );
    166166
    167                 foreach( $to_print as $handle ) {
     167                foreach( (array) $to_print as $handle ) {
    168168                        if ( !in_array($handle, $this->printed) && isset($this->scripts[$handle]) ) {
    169169                                if ( $this->scripts[$handle]->src ) { // Else it defines a group.
    170170                                        $ver = $this->scripts[$handle]->ver ? $this->scripts[$handle]->ver : $wp_db_version;
     
    200200                echo "/* <![CDATA[ */\n";
    201201                echo "\t$object_name = {\n";
    202202                $eol = '';
    203                 foreach ( $this->scripts[$handle]->l10n as $var => $val ) {
     203                foreach ( (array) $this->scripts[$handle]->l10n as $var => $val ) {
    204204                        echo "$eol\t\t$var: \"" . js_escape( $val ) . '"';
    205205                        $eol = ",\n";
    206206                }
     
    218218         * @param bool recursion Used internally when function calls itself
    219219         */
    220220        function all_deps( $handles, $recursion = false ) {
    221                 if ( !$handles = (array) $handles )
     221                if ( !is_array($handles) )
    222222                        return false;
    223223
    224224                foreach ( $handles as $handle ) {
  • taxonomy.php

     
    4141        global $wp_taxonomies;
    4242
    4343        $taxonomies = array();
    44         foreach ( $wp_taxonomies as $taxonomy ) {
     44        foreach ( (array) $wp_taxonomies as $taxonomy ) {
    4545                if ( $object_type === $taxonomy->object_type )
    4646                        $taxonomies[] = $taxonomy->name;
    4747        }
     
    195195        if ( !is_array($taxonomies) )
    196196                $taxonomies = array($taxonomies);
    197197
    198         foreach ( $taxonomies as $taxonomy ) {
     198        foreach ( (array) $taxonomies as $taxonomy ) {
    199199                if ( ! is_taxonomy($taxonomy) )
    200200                        return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
    201201        }
     
    386386
    387387        $children = $terms[$term];
    388388
    389         foreach ( $terms[$term] as $child ) {
     389        foreach ( (array) $terms[$term] as $child ) {
    390390                if ( isset($terms[$child]) )
    391391                        $children = array_merge($children, get_term_children($child, $taxonomy));
    392392        }
     
    513513                $taxonomies = array($taxonomies);
    514514        }
    515515
    516         foreach ( $taxonomies as $taxonomy ) {
     516        foreach ( (array) $taxonomies as $taxonomy ) {
    517517                if ( ! is_taxonomy($taxonomy) )
    518518                        return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
    519519        }
     
    577577                $exclude = '';
    578578                $interms = preg_split('/[\s,]+/',$include);
    579579                if ( count($interms) ) {
    580                         foreach ( $interms as $interm ) {
     580                        foreach ( (array) $interms as $interm ) {
    581581                                if (empty($inclusions))
    582582                                        $inclusions = ' AND ( t.term_id = ' . intval($interm) . ' ';
    583583                                else
     
    594594        if ( !empty($exclude) ) {
    595595                $exterms = preg_split('/[\s,]+/',$exclude);
    596596                if ( count($exterms) ) {
    597                         foreach ( $exterms as $exterm ) {
     597                        foreach ( (array) $exterms as $exterm ) {
    598598                                if (empty($exclusions))
    599599                                        $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
    600600                                else
     
    662662                _pad_term_counts($terms, $taxonomies[0]);
    663663
    664664        // Make sure we show empty categories that have children.
    665         if ( $hierarchical && $hide_empty ) {
     665        if ( $hierarchical && $hide_empty && is_array($terms) ) {
    666666                foreach ( $terms as $k => $term ) {
    667667                        if ( ! $term->count ) {
    668668                                $children = _get_term_children($term->term_id, $terms, $taxonomies[0]);
    669                                 foreach ( $children as $child )
    670                                         if ( $child->count )
    671                                                 continue 2;
     669                                if( is_array($children) )
     670                                        foreach ( $children as $child )
     671                                                if ( $child->count )
     672                                                        continue 2;
    672673
    673674                                // It really is empty
    674675                                unset($terms[$k]);
     
    749750        if ( is_object($term) )
    750751                $do_object = true;
    751752
    752         foreach ( $fields as $field ) {
     753        foreach ( (array) $fields as $field ) {
    753754                if ( $do_object )
    754755                        $term->$field = sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context);
    755756                else
     
    876877        if ( !is_array($taxonomies) )
    877878                $taxonomies = array($taxonomies);
    878879
    879         foreach ( $taxonomies as $taxonomy ) {
     880        foreach ( (array) $taxonomies as $taxonomy ) {
    880881                $terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
    881882                $in_terms = "'" . implode("', '", $terms) . "'";
    882883                $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE object_id = '$object_id' AND term_taxonomy_id IN ($in_terms)");
     
    10011002        if ( !is_array($taxonomies) )
    10021003                $taxonomies = array($taxonomies);
    10031004
    1004         foreach ( $taxonomies as $taxonomy ) {
     1005        foreach ( (array) $taxonomies as $taxonomy ) {
    10051006                if ( ! is_taxonomy($taxonomy) )
    10061007                        return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
    10071008        }
     
    12041205        $tt_ids = array();
    12051206        $term_ids = array();
    12061207
    1207         foreach ($terms as $term) {
     1208        foreach ( (array) $terms as $term) {
    12081209                if ( !strlen(trim($term)) )
    12091210                        continue;
    12101211               
     
    14461447        static $_deferred = array();
    14471448
    14481449        if ( $do_deferred ) {
    1449                 foreach ( array_keys($_deferred) as $tax ) {
     1450                foreach ( (array) array_keys($_deferred) as $tax ) {
    14501451                        wp_update_term_count_now( $_deferred[$tax], $tax );
    14511452                        unset( $_deferred[$tax] );
    14521453                }
     
    14781479                call_user_func($taxonomy->update_count_callback, $terms);
    14791480        } else {
    14801481                // Default count updater
    1481                 foreach ($terms as $term) {
     1482                foreach ( (array) $terms as $term) {
    14821483                        $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) );
    14831484                        $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
    14841485                }
     
    16651666 * @param string $taxonomy Optional. Update Term to this taxonomy in cache
    16661667 */
    16671668function update_term_cache($terms, $taxonomy = '') {
    1668         foreach ( $terms as $term ) {
     1669        foreach ( (array) $terms as $term ) {
    16691670                $term_taxonomy = $taxonomy;
    16701671                if ( empty($term_taxonomy) )
    16711672                        $term_taxonomy = $term->taxonomy;
     
    17361737        if  ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) )
    17371738                return array();
    17381739
    1739         foreach ( $terms as $term ) {
     1740        foreach ( (array) $terms as $term ) {
    17401741                $use_id = false;
    17411742                if ( !is_object($term) ) {
    17421743                        $term = get_term($term, $taxonomy);
     
    17951796
    17961797        $term_items = array();
    17971798
    1798         foreach ( $terms as $key => $term ) {
     1799        foreach ( (array) $terms as $key => $term ) {
    17991800                $terms_by_id[$term->term_id] = & $terms[$key];
    18001801                $term_ids[$term->term_taxonomy_id] = $term->term_id;
    18011802        }
     
    18441845function _update_post_term_count( $terms ) {
    18451846        global $wpdb;
    18461847
    1847         foreach ( $terms as $term ) {
     1848        foreach ( (array) $terms as $term ) {
    18481849                $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 ) );
    18491850                $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
    18501851        }
  • user.php

     
    101101                        return '';
    102102        }
    103103
    104         foreach ($metas as $meta)
     104        foreach ( (array) $metas as $meta)
    105105                $values[] = maybe_unserialize($meta->meta_value);
    106106
    107107        if ( count($values) == 1 )
     
    216216                if ( $show_option_none )
    217217                        $output .= "\t<option value='-1'>$show_option_none</option>\n";
    218218
    219                 foreach ( $users as $user ) {
     219                foreach ( (array) $users as $user ) {
    220220                        $user->ID = (int) $user->ID;
    221221                        $_selected = $user->ID == $selected ? " selected='selected'" : '';
    222222                        $output .= "\t<option value='$user->ID'$_selected>" . wp_specialchars($user->$show) . "</option>\n";
     
    241241        $wpdb->show_errors($show);
    242242
    243243        if ( $metavalues ) {
    244                 foreach ( $metavalues as $meta ) {
     244                foreach ( (array) $metavalues as $meta ) {
    245245                        $value = maybe_unserialize($meta->meta_value);
    246246                        $user->{$meta->meta_key} = $value;
    247247                }
  • widgets.php

     
    204204                $index = "sidebar-$index";
    205205        } else {
    206206                $index = sanitize_title($index);
    207                 foreach ( $wp_registered_sidebars as $key => $value ) {
     207                foreach ( (array) $wp_registered_sidebars as $key => $value ) {
    208208                        if ( sanitize_title($value['name']) == $index ) {
    209209                                $index = $key;
    210210                                break;
     
    220220        $sidebar = $wp_registered_sidebars[$index];
    221221
    222222        $did_one = false;
    223         foreach ( $sidebars_widgets[$index] as $id ) {
     223        foreach ( (array) $sidebars_widgets[$index] as $id ) {
    224224                $callback = $wp_registered_widgets[$id]['callback'];
    225225
    226226                $params = array_merge(array($sidebar), (array) $wp_registered_widgets[$id]['params']);
     
    263263function is_dynamic_sidebar() {
    264264        global $wp_registered_widgets, $wp_registered_sidebars;
    265265        $sidebars_widgets = get_option('sidebars_widgets');
    266         foreach ( $wp_registered_sidebars as $index => $sidebar ) {
     266        foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
    267267                if ( count($sidebars_widgets[$index]) ) {
    268                         foreach ( $sidebars_widgets[$index] as $widget )
     268                        foreach ( (array) $sidebars_widgets[$index] as $widget )
    269269                                if ( array_key_exists($widget, $wp_registered_widgets) )
    270270                                        return true;
    271271                }
     
    286286
    287287        switch ( $sidebars_widgets['array_version'] ) {
    288288                case 1 :
    289                         foreach ( $sidebars_widgets as $index => $sidebar )
     289                        foreach ( (array) $sidebars_widgets as $index => $sidebar )
    290290                        if ( is_array($sidebar) )
    291                         foreach ( $sidebar as $i => $name ) {
     291                        foreach ( (array) $sidebar as $i => $name ) {
    292292                                $id = strtolower($name);
    293293                                if ( isset($wp_registered_widgets[$id]) ) {
    294294                                        $_sidebars_widgets[$index][$i] = $id;
     
    309309                        $sidebars = array_keys( $wp_registered_sidebars );
    310310                        if ( !empty( $sidebars ) ) {
    311311                                // Move the known-good ones first
    312                                 foreach ( $sidebars as $id ) {
     312                                foreach ( (array) $sidebars as $id ) {
    313313                                        if ( array_key_exists( $id, $sidebars_widgets ) ) {
    314314                                                $_sidebars_widgets[$id] = $sidebars_widgets[$id];
    315315                                                unset($sidebars_widgets[$id], $sidebars[$id]);
     
    344344
    345345        $defaults = array();
    346346
    347         foreach ( $wp_registered_sidebars as $index => $sidebar )
     347        foreach ( (array) $wp_registered_sidebars as $index => $sidebar )
    348348                $defaults[$index] = array();
    349349
    350350        return $defaults;
     
    598598                else
    599599                        $this_sidebar = array();
    600600
    601                 foreach ( $this_sidebar as $_widget_id ) {
     601                foreach ( (array) $this_sidebar as $_widget_id ) {
    602602                        if ( 'wp_widget_text' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
    603603                                $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
    604604                                unset($options[$widget_number]);
     
    648648                wp_register_widget_control( 'text-1', $name, 'wp_widget_text_control', $control_ops, array( 'number' => -1 ) );
    649649        }
    650650
    651         foreach ( array_keys($options) as $o ) {
     651        foreach ( (array) array_keys($options) as $o ) {
    652652                // Old widgets can have null values for some reason
    653653                if ( !isset($options[$o]['title']) || !isset($options[$o]['text']) )
    654654                        continue;
     
    687687
    688688<script type='text/javascript'>
    689689/* <![CDATA[ */
    690     var dropdown = document.getElementById("cat");
    691     function onCatChange() {
     690        var dropdown = document.getElementById("cat");
     691        function onCatChange() {
    692692                if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    693693                        location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
    694694                }
    695     }
    696     dropdown.onchange = onCatChange;
     695        }
     696        dropdown.onchange = onCatChange;
    697697/* ]]> */
    698698</script>
    699699
     
    732732                else
    733733                        $this_sidebar = array();
    734734               
    735                 foreach ( $this_sidebar as $_widget_id ) {
     735                foreach ( (array) $this_sidebar as $_widget_id ) {
    736736                        if ( 'wp_widget_categories' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
    737737                                $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
    738738                                unset($options[$widget_number]);
    739                         }   
     739                        }
    740740                }
    741741
    742742                foreach ( (array) $_POST['widget-categories'] as $widget_number => $widget_cat ) {
     
    809809                wp_register_widget_control( 'categories-1', $name, 'wp_widget_categories_control', array( 'id_base' => 'categories' ), array( 'number' => -1 ) );
    810810        }
    811811
    812         foreach ( array_keys($options) as $o ) {
     812        foreach ( (array) array_keys($options) as $o ) {
    813813                // Old widgets can have null values for some reason
    814814                if ( !isset($options[$o]['title']) )
    815815                        continue;
     
    932932                <?php echo $before_widget; ?>
    933933                        <?php echo $before_title . $title . $after_title; ?>
    934934                        <ul id="recentcomments"><?php
    935                         if ( $comments ) : foreach ($comments as $comment) :
     935                        if ( $comments ) : foreach ( (array) $comments as $comment) :
    936936                        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>';
    937937                        endforeach; endif;?></ul>
    938938                <?php echo $after_widget; ?>
     
    10371037        if ( is_array( $rss->items ) && !empty( $rss->items ) ) {
    10381038                $rss->items = array_slice($rss->items, 0, $num_items);
    10391039                echo '<ul>';
    1040                 foreach ($rss->items as $item ) {
     1040                foreach ( (array) $rss->items as $item ) {
    10411041                        while ( strstr($item['link'], 'http') != $item['link'] )
    10421042                                $item['link'] = substr($item['link'], 1);
    10431043                        $link = clean_url(strip_tags($item['link']));
     
    10761076                $options = array();
    10771077
    10781078        $urls = array();
    1079         foreach ( $options as $option )
     1079        foreach ( (array) $options as $option )
    10801080                if ( isset($option['url']) )
    10811081                        $urls[$option['url']] = true;
    10821082
     
    10891089                else
    10901090                        $this_sidebar = array();
    10911091       
    1092                 foreach ( $this_sidebar as $_widget_id ) {
     1092                foreach ( (array) $this_sidebar as $_widget_id ) {
    10931093                        if ( 'wp_widget_rss' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
    10941094                                $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
    10951095                                unset($options[$widget_number]);
     
    11721172                wp_register_widget_control( 'rss-1', $name, 'wp_widget_rss_control', $control_ops, array( 'number' => -1 ) );
    11731173        }
    11741174
    1175         foreach ( array_keys($options) as $o ) {
     1175        foreach ( (array) array_keys($options) as $o ) {
    11761176                // Old widgets can have null values for some reason
    11771177                if ( !isset($options[$o]['url']) || !isset($options[$o]['title']) || !isset($options[$o]['items']) )
    11781178                        contine;
  • wp-db.php

     
    9999                $old_prefix = $this->prefix;
    100100                $this->prefix = $prefix;
    101101
    102                 foreach ( $this->tables as $table )
     102                foreach ( (array) $this->tables as $table )
    103103                        $this->$table = $this->prefix . $table;
    104104
    105105                if ( defined('CUSTOM_USER_TABLE') )
     
    315315        function update($table, $data, $where){
    316316                $data = add_magic_quotes($data);
    317317                $bits = $wheres = array();
    318                 foreach ( array_keys($data) as $k )
     318                foreach ( (array) array_keys($data) as $k )
    319319                        $bits[] = "`$k` = '$data[$k]'";
    320320
    321321                if ( is_array( $where ) )
     
    413413                } elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
    414414                        if ( $this->last_result ) {
    415415                                $i = 0;
    416                                 foreach( $this->last_result as $row ) {
     416                                foreach( (array) $this->last_result as $row ) {
    417417                                        $new_array[$i] = (array) $row;
    418418                                        if ( $output == ARRAY_N ) {
    419419                                                $new_array[$i] = array_values($new_array[$i]);
     
    437437                if ( $this->col_info ) {
    438438                        if ( $col_offset == -1 ) {
    439439                                $i = 0;
    440                                 foreach($this->col_info as $col ) {
     440                                foreach( (array) $this->col_info as $col ) {
    441441                                        $new_array[$i] = $col->{$info_type};
    442442                                        $i++;
    443443                                }
     
    519519                $bt = debug_backtrace();
    520520                $caller = '';
    521521
    522                 foreach ( $bt as $trace ) {
     522                foreach ( (array) $bt as $trace ) {
    523523                        if ( @$trace['class'] == __CLASS__ )
    524524                                continue;
    525525                        elseif ( strtolower(@$trace['function']) == 'call_user_func_array' )