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/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);
Note: See TracChangeset for help on using the changeset viewer.