Opened 2 years ago
Last modified 9 months ago
#57136 new defect (bug)
wp_list_pluck's key argument not working correctly when its zero
Reported by: | dgwatkins | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | General | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description (last modified by )
This is better explained with an example:
wp> var_dump( wp_list_pluck( [ [ 'key1', 'val1' ], [ 'key2', 'val2' ] ], 1, 0 )); array(2) { [0]=> string(4) "val1" [1]=> string(4) "val2" }
See the missing key?
If we try with array_column it works correctly:
wp> var_dump( array_column( [ [ 'key1', 'val1' ], [ 'key2', 'val2' ] ], 1, 0 )); array(2) { ["key1"]=> string(4) "val1" ["key2"]=> string(4) "val2" }
Attachments (2)
Change History (9)
This ticket was mentioned in PR #3643 on WordPress/wordpress-develop by @riccardodicurti.
2 years ago
#1
- Keywords has-patch added
#3
@
2 years ago
Hi @afragen, may I ask what you mean with "related #56650". Should this ticket be closed? I don't see the same change in the other ticket.
#4
@
2 years ago
I said _related_ as the other ticket also deals with arguments to wp_list_pluck()
. The other ticket goes about solving this issue a bit differently and also includes tests.
If you could test the PR for the ticket and see if it also fixes your issue that would be great. If it does, I would recommend closing this ticket as a duplicate.
#5
@
2 years ago
- Keywords needs-testing added
- Version set to trunk
Note: See
TracTickets for help on using
tickets.
[[[
Trac ticket:
---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.](https://core.trac.wordpress.org/ticket/57136)
](https://core.trac.wordpress.org/ticket/57136)](https://core.trac.wordpress.org/ticket/57136)