[wp-trac] [WordPress Trac] #22342: WP_DEBUG "undefined index" notices in get_metadata() for empty arrays
WordPress Trac
noreply at wordpress.org
Wed Jul 10 20:39:51 UTC 2013
#22342: WP_DEBUG "undefined index" notices in get_metadata() for empty arrays
-------------------------------------------------+-------------------------
Reporter: doublesharp | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting
Component: Warnings/Notices | Review
Severity: minor | Version: 3.1
Keywords: has-patch needs-testing dev- | Resolution:
feedback 2nd-opinion |
-------------------------------------------------+-------------------------
Comment (by JD55):
I think there is really a larger issue here. I don't think that the logic
behind this is correct:
{{{
if ( $single && is_array( $check ) )
return $check[0];
}}}
This makes it impossible to return an array for the single meta value,
which is a real problem if your meta value is stored as an array. I've
attached a some code that demonstrates this. I think that this check
should be removed completely, and `$check` should be returned 'raw'. As
[[ticket:14766#comment:17|nacin]] said in a related ticket:
>In many locations throughout core, we simply trust the plugin to return
the right data, and if they don't, then the sky may fall on their head.
So it should just be this:
{{{
if ( null !== $check )
return $check;
}}}
It should be up to the plugin to return an appropriate value based on
`$single`. It has to be, because we have no way of knowing whether a value
is appropriate.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22342#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list