Make WordPress Core


Ignore:
Timestamp:
08/06/2008 08:31:54 PM (13 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/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>';
Note: See TracChangeset for help on using the changeset viewer.