Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#2160 closed defect (bug) (fixed)

get_post_custom_values() broken?

Reported by: jasontromm Owned by: anonymous
Priority: normal Milestone:
Component: Template Version: 2.0
Severity: major Keywords: meta tags custom values template functions bg|has-patch bg|commit
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 7 years ago.
2160.2.diff (476 bytes) - added by davidhouse 7 years ago.
minus debugging cruft
2160.3.diff (476 bytes) - added by davidhouse 7 years ago.
minus debugging cruft
get_post_custom_values.patch (359 bytes) - added by Kafkaesqui 7 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 7 years ago.
post custom cleanup

Download all attachments as: .zip

Change History (15)

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 :))

minus debugging cruft

minus debugging cruft

  • Keywords bg|has-patch added
  • Keywords bg|commit added
  • Milestone set to 2.0.1

comment:5   matt7 years ago

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

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

  • 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.

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

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

ryan7 years ago

post custom cleanup

comment:8   ryan7 years ago

More comprehensive patch that cleans up post_custom a bit.

comment:9   ryan7 years ago

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

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

  • Milestone 2.0.1 deleted

Milestone 2.0.1 deleted

Note: See TracTickets for help on using tickets.