Ticket #2160 (closed defect (bug): fixed)

Opened 6 years ago

Last modified 5 years ago

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

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

Change History

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   matt6 years ago

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

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

  • Status changed from closed to reopened
  • Resolution fixed deleted

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.

ryan6 years ago

post custom cleanup

comment:8   ryan6 years ago

More comprehensive patch that cleans up post_custom a bit.

comment:9   ryan6 years ago

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

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