WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#2160 closed defect (bug) (fixed)

get_post_custom_values() broken?

Reported by: jasontromm Owned by:
Milestone: Priority: normal
Severity: major Version: 2.0
Component: Template Keywords: meta tags custom values template functions bg|has-patch bg|commit
Focuses: Cc:

Description

get_post_custom_values() appears to be broken in WP 2.0. I know there are entries in the wp_postmeta table for the entry I'm looking at, but they're not retrieved by get_post_custom_values(). (I'm using the multi-topic-icon plugin.)

Attachments (5)

2160.diff (843 bytes) - added by davidhouse 11 years ago.
2160.2.diff (476 bytes) - added by davidhouse 11 years ago.
minus debugging cruft
2160.3.diff (476 bytes) - added by davidhouse 11 years ago.
minus debugging cruft
get_post_custom_values.patch (359 bytes) - added by Kafkaesqui 11 years ago.
Has get_post_custom_values() return $post_meta_cache[$id][$key] if $key param provided.
meta.diff (3.4 KB) - added by ryan 11 years ago.
post custom cleanup

Download all attachments as: .zip

Change History (15)

#1 @davidhouse
11 years ago

I'm not entirely sure as to how that function should work, so I guessed. It was the same in 1.5.2 as it is now, but that is a buggy state. I've attached a patch that works in the following way:

get_post_custom_values() has an optional values parameter. If you pass it, the function will return all values with that key. If you don't pass it, or you pass an empty parameter, the function acts exactly like get_post_custom (in fact, it just calls get_post_custom :))

@davidhouse
11 years ago

@davidhouse
11 years ago

minus debugging cruft

@davidhouse
11 years ago

minus debugging cruft

#2 @davidhouse
11 years ago

  • Keywords bg|has-patch added

#3 @davidhouse
11 years ago

  • Keywords bg|commit added

#4 @davidhouse
11 years ago

  • Milestone set to 2.0.1

#5 @matt
11 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [3448]) get_post_custom_values update. Fixes #2160

#6 @Kafkaesqui
11 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm reopening the ticket because the logic in the fix makes no sense.

If no $key param is provided get_post_custom_values() returns $post_meta_cache[$id], but with a $key it returns the output of get_post_custom(). That's effectively the same thing!

Providing a {$}key never returns values for that key, but rather an array of all keys and values.

#7 @Kafkaesqui
11 years ago

I'm uploading a patch which reverts get_post_custom_values() to its original intent, at least when $key param is provided.

@Kafkaesqui
11 years ago

Has get_post_custom_values() return $post_meta_cache[$id][$key] if $key param provided.

@ryan
11 years ago

post custom cleanup

#8 @ryan
11 years ago

More comprehensive patch that cleans up post_custom a bit.

#9 @ryan
11 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [3486]) post_custom cleanup. fixes #2160

#10 @anonymous
10 years ago

  • Milestone 2.0.1 deleted

Milestone 2.0.1 deleted

Note: See TracTickets for help on using tickets.