[wp-trac] [WordPress Trac] #59774: Undefined array key when using wp_list_pluck function
WordPress Trac
noreply at wordpress.org
Thu Feb 22 21:50:26 UTC 2024
#59774: Undefined array key when using wp_list_pluck function
-------------------------------------------------+-------------------------
Reporter: iamarunchaitanyajami | Owner:
| hellofromTonya
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.5
Component: General | Version: 5.1
Severity: normal | Resolution: fixed
Keywords: has-patch has-testing-info has- | Focuses:
unit-tests commit |
-------------------------------------------------+-------------------------
Changes (by hellofromTonya):
* status: reviewing => closed
* resolution: => fixed
Comment:
In [changeset:"57698" 57698]:
{{{
#!CommitTicketReference repository="" revision="57698"
General: Handle missing field in WP_List_Util::pluck().
Handles when the `$field` (i.e. key or property) is missing in one of the
`$input_list` items by checking the key (array) or property (object)
exists before using it for assignment.
Resolves the following bugs:
* a PHP warning for undefined key|property.
* `null` being set for that array or object within the returned list.
The changes resolve the issues in both `WP_List_Util::pluck()` (if invoked
directly) and `wp_list_pluck()`.
Also includes an additional test for the scenario where the
`wp_list_pluck()` `$index_key` is not `null`, the `$field` is missing in
one of the `$input_list` items.
Follow-up to [55423], [51663], [42527], [38928].
Props iamarunchaitanyajami, davidbinda, hellofromTonya, helgatheviking.
Fixes #59774.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59774#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list