[wp-trac] [WordPress Trac] #35087: Make sure $list in wp_list_pluck() is an array
WordPress Trac
noreply at wordpress.org
Mon Dec 14 23:57:46 UTC 2015
#35087: Make sure $list in wp_list_pluck() is an array
--------------------------+-----------------------------
Reporter: josephscott | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I'm seeing wp_list_pluck() being used lots of times without checking to
see if $list is really an array first. This results in many PHP warnings:
{{{
Invalid argument supplied for foreach()
}}}
Ideally code making use of wp_list_pluck() would make sure the parameters
are the correct type first. Since that isn't happening it is time for
wp_list_pluck() to take a more defensive stance.
The most direct path to addressing this is to cast $list to an array as
part of the foreach process. I'll be adding a simple patch to this ticket
that does this and adds a new unit test for this condition.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35087>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list