Make WordPress Core

Changeset 30982


Ignore:
Timestamp:
12/20/2014 10:46:53 PM (9 years ago)
Author:
wonderboymusic
Message:

For clarity, initialize some arrays that previously were only assigned via short circuit in loops.

See #30799.

Location:
trunk/src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/nav-menu.php

    r30648 r30982  
    12531253function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
    12541254    $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) );
    1255 
     1255    $messages = array();
    12561256    $menu_items = array();
    12571257    // Index menu items by db ID
  • trunk/src/wp-admin/includes/template.php

    r30890 r30982  
    302302    $default = 1;
    303303
     304    $checked_categories = array();
     305
    304306    if ( $link_id ) {
    305307        $checked_categories = wp_get_link_cats( $link_id );
    306308        // No selected categories, strange
    307         if ( ! count( $checked_categories ) )
     309        if ( ! count( $checked_categories ) ) {
    308310            $checked_categories[] = $default;
     311        }
    309312    } else {
    310313        $checked_categories[] = $default;
  • trunk/src/wp-admin/includes/theme.php

    r30944 r30982  
    431431
    432432    WP_Theme::sort_by_name( $themes );
     433
     434    $parents = array();
     435
    433436    foreach ( $themes as $theme ) {
    434437        $slug = $theme->get_stylesheet();
     
    470473
    471474    // Remove 'delete' action if theme has an active child
    472     if ( isset( $parents ) && array_key_exists( $current_theme, $parents ) ) {
     475    if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) {
    473476        unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] );
    474477    }
  • trunk/src/wp-admin/includes/upgrade.php

    r30742 r30982  
    17871787        if ($tableindices) {
    17881788            // Clear the index array.
    1789             unset($index_ary);
     1789            $index_ary = array();
    17901790
    17911791            // For every index in the table.
  • trunk/src/wp-includes/category-template.php

    r30681 r30982  
    12901290        return false;
    12911291
     1292    $links = array();
     1293
    12921294    foreach ( $terms as $term ) {
    12931295        $link = get_term_link( $term, $taxonomy );
    1294         if ( is_wp_error( $link ) )
     1296        if ( is_wp_error( $link ) ) {
    12951297            return $link;
    1296         $term_links[] = '<a href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>';
     1298        }
     1299        $links[] = '<a href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>';
    12971300    }
    12981301
     
    13051308     * @since 2.5.0
    13061309     *
    1307      * @param array $term_links An array of term links.
    1308      */
    1309     $term_links = apply_filters( "term_links-$taxonomy", $term_links );
     1310     * @param array $links An array of term links.
     1311     */
     1312    $term_links = apply_filters( "term_links-$taxonomy", $links );
    13101313
    13111314    return $before . join( $sep, $term_links ) . $after;
  • trunk/src/wp-includes/default-widgets.php

    r30281 r30982  
    12671267
    12681268    public function update( $new_instance, $old_instance ) {
     1269        $instance = array();
    12691270        $instance['title'] = strip_tags(stripslashes($new_instance['title']));
    12701271        $instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
  • trunk/src/wp-includes/formatting.php

    r30766 r30982  
    10231023        $string = strtr($string, $chars);
    10241024    } else {
     1025        $chars = array();
    10251026        // Assume ISO-8859-1 if not UTF-8
    10261027        $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)
     
    10381039
    10391040        $string = strtr($string, $chars['in'], $chars['out']);
     1041        $double_chars = array();
    10401042        $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));
    10411043        $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');
  • trunk/src/wp-includes/general-template.php

    r30854 r30982  
    14391439        if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
    14401440            $results = $wpdb->get_results( $query );
    1441             $cache[ $key ] = $results;
    14421441            wp_cache_set( $key, $results, 'posts' );
    14431442        }
     
    16581657    <tr>';
    16591658
     1659    $daywithpost = array();
     1660
    16601661    // Get days with posts
    16611662    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
     
    16671668            $daywithpost[] = $daywith[0];
    16681669        }
    1669     } else {
    1670         $daywithpost = array();
    16711670    }
    16721671
  • trunk/src/wp-includes/media.php

    r30674 r30982  
    587587    // get the best one for a specified set of dimensions
    588588    if ( is_array($size) && !empty($imagedata['sizes']) ) {
     589        $areas = array();
     590
    589591        foreach ( $imagedata['sizes'] as $_size => $data ) {
    590592            // already cropped to width or height; so use this size
  • trunk/src/wp-includes/ms-deprecated.php

    r30176 r30982  
    167167    $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
    168168
     169    $blog_list = array();
    169170    foreach ( (array) $blogs as $details ) {
    170171        $blog_list[ $details['blog_id'] ] = $details;
    171172        $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" );
    172173    }
    173     unset( $blogs );
    174     $blogs = $blog_list;
    175 
    176     if ( false == is_array( $blogs ) )
     174
     175    if ( ! $blog_list ) {
    177176        return array();
    178 
    179     if ( $num == 'all' )
    180         return array_slice( $blogs, $start, count( $blogs ) );
    181     else
    182         return array_slice( $blogs, $start, $num );
     177    }
     178
     179    if ( $num == 'all' ) {
     180        return array_slice( $blog_list, $start, count( $blog_list ) );
     181    } else {
     182        return array_slice( $blog_list, $start, $num );
     183    }
    183184}
    184185
  • trunk/src/wp-includes/ms-load.php

    r30543 r30982  
    309309    }
    310310
     311    $paths = array();
     312
    311313    while ( count( $path_segments ) ) {
    312314        $paths[] = '/' . implode( '/', $path_segments ) . '/';
  • trunk/src/wp-includes/post.php

    r30735 r30982  
    353353        return $kids;
    354354    } elseif ( $output == ARRAY_A ) {
    355         foreach ( (array) $kids as $kid )
     355        $weeuns = array();
     356        foreach ( (array) $kids as $kid ) {
    356357            $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
     358        }
    357359        return $weeuns;
    358360    } elseif ( $output == ARRAY_N ) {
    359         foreach ( (array) $kids as $kid )
     361        $babes = array();
     362        foreach ( (array) $kids as $kid ) {
    360363            $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
     364        }
    361365        return $babes;
    362366    } else {
     
    16821686        $object->labels['all_items'] = $object->labels['menu_name'];
    16831687
    1684     foreach ( $nohier_vs_hier_defaults as $key => $value )
    1685             $defaults[$key] = $object->hierarchical ? $value[1] : $value[0];
    1686 
     1688    $defaults = array();
     1689    foreach ( $nohier_vs_hier_defaults as $key => $value ) {
     1690        $defaults[$key] = $object->hierarchical ? $value[1] : $value[0];
     1691    }
    16871692    $labels = array_merge( $defaults, $object->labels );
    16881693    return (object)$labels;
     
    25112516    if ( is_string($post_mime_types) )
    25122517        $post_mime_types = array_map('trim', explode(',', $post_mime_types));
     2518
     2519    $wheres = array();
     2520
    25132521    foreach ( (array) $post_mime_types as $mime_type ) {
    25142522        $mime_type = preg_replace('/\s/', '', $mime_type);
     
    51415149        }
    51425150
     5151        $types = array();
    51435152        // Icon basename - extension = MIME wildcard.
    51445153        foreach ( $icon_files as $file => $uri )
     
    55145523            $ptypes = $post_type;
    55155524        } elseif ( 'any' == $post_type ) {
     5525            $ptypes = array();
    55165526            // Just use the post_types in the supplied posts.
    5517             foreach ( $posts as $post )
     5527            foreach ( $posts as $post ) {
    55185528                $ptypes[] = $post->post_type;
     5529            }
    55195530            $ptypes = array_unique($ptypes);
    55205531        } else {
  • trunk/src/wp-includes/rewrite.php

    r30703 r30982  
    12891289        //build a list from the rewritecode and queryreplace arrays, that will look something like
    12901290        //tagname=$matches[i] where i is the current $i
     1291        $queries = array();
    12911292        for ( $i = 0; $i < $num_tokens; ++$i ) {
    12921293            if ( 0 < $i )
     
    13291330
    13301331            //get the 'tagname=$matches[i]'
    1331             $query = ( isset($queries) && is_array($queries) && !empty($num_toks) ) ? $queries[$num_toks - 1] : '';
     1332            $query = ( ! empty( $num_toks ) && isset( $queries[$num_toks - 1] ) ) ? $queries[$num_toks - 1] : '';
    13321333
    13331334            //set up $ep_mask_specific which is used to match more specific URL types
  • trunk/src/wp-includes/taxonomy.php

    r30954 r30982  
    38903890
    38913891    $term_items = array();
     3892    $terms_by_id = array();
     3893    $term_ids = array();
    38923894
    38933895    foreach ( (array) $terms as $key => $term ) {
  • trunk/src/wp-includes/theme.php

    r30787 r30982  
    407407
    408408    $wp_theme_directories = (array) $wp_theme_directories;
     409    $relative_theme_roots = array();
    409410
    410411    // Set up maybe-relative, maybe-absolute array of theme directories.
Note: See TracChangeset for help on using the changeset viewer.