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