Skip to content
Browse files

maybe_unserialize the array members not the array when multple post m…

…eta items are returned. Fixes #7623 for 2.6 branch props andy.

git-svn-id: http://svn.automattic.com/wordpress/branches/2.6@8825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent c11dc44 commit fc83a8735ccaedee86978d7388c31c67c272d45f westi committed Sep 5, 2008
Showing with 7 additions and 14 deletions.
  1. +7 −14 wp-includes/post.php
View
21 wp-includes/post.php
@@ -594,27 +594,20 @@ function get_post_meta($post_id, $key, $single = false) {
$meta_cache = wp_cache_get($post_id, 'post_meta');
+ if ( !$meta_cache ) {
+ update_postmeta_cache($post_id);
+ $meta_cache = wp_cache_get($post_id, 'post_meta');
+ }
+
if ( isset($meta_cache[$key]) ) {
if ( $single ) {
return maybe_unserialize( $meta_cache[$key][0] );
} else {
- return maybe_unserialize( $meta_cache[$key] );
+ return array_map('maybe_unserialize', $meta_cache[$key]);
}
}
- if ( !$meta_cache ) {
- update_postmeta_cache($post_id);
- $meta_cache = wp_cache_get($post_id, 'post_meta');
- }
-
- if ( $single ) {
- if ( isset($meta_cache[$key][0]) )
- return maybe_unserialize($meta_cache[$key][0]);
- else
- return '';
- } else {
- return maybe_unserialize($meta_cache[$key]);
- }
+ return '';
}
/**

0 comments on commit fc83a87

Please sign in to comment.
Something went wrong with that request. Please try again.