Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/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.