Make WordPress Core

Opened 2 years ago

Closed 22 months ago

Last modified 22 months ago

#56650 closed defect (bug) (fixed)

Add more error checking to WP_List_Util::pluck

Reported by: afragen's profile afragen Owned by: audrasjb's profile audrasjb
Milestone: 6.2 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch has-unit-tests commit
Focuses: Cc:

Description (last modified by afragen)

$value is checked to see if it is an object, but the else doesn't check to see if $value is an array.

I've found instances where null is passed to WP_List_Util::pluck() resulting in an error. Some additional error checking in the else should solve this.

Change History (19)

This ticket was mentioned in PR #3323 on WordPress/wordpress-develop by afragen.


2 years ago
#1

Add a check to the else as elseif to ensure $field is an array when it is treated as such.

Trac ticket: https://core.trac.wordpress.org/ticket/56650

This ticket was mentioned in Slack in #core by afragen. View the logs.


2 years ago

#3 @afragen
2 years ago

  • Description modified (diff)

afragen commented on PR #3323:


2 years ago
#4

@costdev I think I've resolved the above issues.

This ticket was mentioned in Slack in #core by afragen. View the logs.


2 years ago

#6 @afragen
2 years ago

  • Keywords has-unit-tests added

This ticket was mentioned in Slack in #core by afragen. View the logs.


2 years ago

#8 @audrasjb
2 years ago

  • Owner set to audrasjb
  • Status changed from new to reviewing

Self assigning for final review.

#9 @audrasjb
2 years ago

@afragen I added two questions in the PR :)
Otherwise, it looks good to me.

#10 @afragen
2 years ago

@audrasjb I’m not seeing your questions.

#11 @audrasjb
2 years ago

@afragen sorry I forgot to submit the review :D

#12 @audrasjb
2 years ago

  • Milestone changed from Awaiting Review to 6.2

Thanks for the follow-up commit ;)
Moving this to milestone 6.2.

This ticket was mentioned in Slack in #core-upgrade-install by afragen. View the logs.


2 years ago

This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.


22 months ago

#15 @mukesh27
22 months ago

This ticket was discussed during the recent bug scrub. It looks like it's unlikely that work will be done on this during the 6.2 cycle.

@audrasjb PR ready for re-review. Is this still possible to land in 6.2, or should it be moved to Future Release for now?

This ticket was mentioned in Slack in #core by costdev. View the logs.


22 months ago

#17 @audrasjb
22 months ago

  • Keywords commit added

#18 @SergeyBiryukov
22 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 55423:

General: Add more error checking to WP_List_Util::pluck().

Values for the input array in WP_List_Util::pluck() or wp_list_pluck() must be either objects or arrays.

This commit adds a check to ensure that the value retrieved in the loop is an array before treating it as such, and throws a _doing_it_wrong() notice if it is neither an object nor an array.

Follow-up to [14108], [15686], [18602], [28900], [38928].

Props afragen, costdev, audrasjb.
Fixes #56650.

@SergeyBiryukov commented on PR #3323:


22 months ago
#19

Thanks for the PR! Merged in r55423.

Note: As wp_list_pluck() is just a wrapper and the actual source code change was in WP_List_Util::pluck(), I have moved the tests to the class where all the other tests for WP_List_Util are located.

Note: See TracTickets for help on using tickets.