WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 7 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 8 years ago.
2160.2.diff (476 bytes) - added by davidhouse 8 years ago.
minus debugging cruft
2160.3.diff (476 bytes) - added by davidhouse 8 years ago.
minus debugging cruft
get_post_custom_values.patch (359 bytes) - added by Kafkaesqui 8 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 8 years ago.
post custom cleanup

Download all attachments as: .zip

Change History (15)

comment:1 davidhouse8 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 :))

davidhouse8 years ago

davidhouse8 years ago

minus debugging cruft

davidhouse8 years ago

minus debugging cruft

comment:2 davidhouse8 years ago

  • Keywords bg|has-patch added

comment:3 davidhouse8 years ago

  • Keywords bg|commit added

comment:4 davidhouse8 years ago

  • Milestone set to 2.0.1

comment:5 matt8 years ago

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

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

comment:6 Kafkaesqui8 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.

comment:7 Kafkaesqui8 years ago

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

Kafkaesqui8 years ago

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

ryan8 years ago

post custom cleanup

comment:8 ryan8 years ago

More comprehensive patch that cleans up post_custom a bit.

comment:9 ryan8 years ago

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

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

comment:10 anonymous7 years ago

  • Milestone 2.0.1 deleted

Milestone 2.0.1 deleted

Note: See TracTickets for help on using tickets.