Opened 5 years ago

Closed 4 years ago

#7014 closed defect (bug) (invalid)

get_post_custom() doesn't always return an array

Reported by: donncha Owned by: anonymous
Priority: high Milestone:
Component: General Version: 2.5.1
Severity: normal Keywords: 2nd-opinion
Cc:

Description

I have noticed that get_post_custom() doesn't always return an array. wp-includes/feed.php uses this function in a foreach loop at line 164 in WP 2.5.1 resulting in an error message stating "Invalid argument supplied for foreach() in ...wp-includes/feed.php on line 164"

I think update_postmeta_cache() in wp-includes/post.php should cast it's return value as an array possibly.

Change History (6)

Casting the return of get_post_custom() as an array fixes this problem.

comment:3   ryan5 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

  • Milestone changed from 2.9 to 2.8

seems invalid:

	foreach ( (array) $ids as $id ) {
		if ( ! isset($cache[$id]) )
			$cache[$id] = array();
	}

	foreach ( (array) array_keys($cache) as $post)
		wp_cache_set($post, $cache[$post], 'post_meta');

or am I missing something?

  • Keywords 2nd-opinion added
  • Milestone changed from 2.8 to Future Release
  • Milestone changed from Future Release to 2.9
  • Priority changed from normal to high
  • Milestone 2.9 deleted
  • Resolution set to invalid
  • Status changed from new to closed

returns an array even with a non-existing post.

Note: See TracTickets for help on using tickets.