WordPress.org

Make WordPress Core

Opened 3 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#51720 closed defect (bug) (fixed)

Make wp_array_get internal for now. Add tests to _wp_array_get;

Reported by: jorgefilipecosta Owned by: johnbillion
Milestone: 5.6 Priority: normal
Severity: normal Version: 5.6
Component: General Keywords: has-patch has-unit-tests commit
Focuses: Cc:

Description (last modified by jorgefilipecosta)

According to feedback received at #51461. This ticket contains a patch to make wp_array_get internal.
After more core code uses it we can decide if the function is valuable and something we want to expose or not.
This Patch also adds test cases and does some enhancements to the function wp_array_get to make it more similar to lodash namely the default value and the way null is handled.

Change History (13)

This ticket was mentioned in PR #692 on WordPress/wordpress-develop by jorgefilipecosta.


3 weeks ago

According to feedback received in ticket 51461. This PR contains makes wp_array_get internal.
After more core code uses it we can decide if the function is valuable and something we want to expose or not.

Trac ticket: core.trac.wordpress.org/ticket/51720

#2 @SergeyBiryukov
3 weeks ago

  • Description modified (diff)

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


3 weeks ago

#4 @johnbillion
3 weeks ago

@jorgefilipecosta Can you point us to the upstream tests for this function please? It would be worth bringing them into core regardless of whether it's a private function or not.

Last edited 3 weeks ago by johnbillion (previous) (diff)

#5 @jorgefilipecosta
2 weeks ago

  • Description modified (diff)
  • Summary changed from Make wp_array_get internal for now to Make wp_array_get internal for now. Add tests to _wp_array_get;

#6 @jorgefilipecosta
2 weeks ago

Hi @johnbillion we did not have tests for this function. I added tests to this Patch/PR.

#7 @hellofromTonya
2 weeks ago

  • Keywords has-unit-tests added

Tests were added yesterday.

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


2 weeks ago

#9 @Hareesh Pillai
2 weeks ago

Thanks for the test.

Minor change - I guess we'll have to update the function name in the docblock in the tests file.

 * Tests wp_array_slice_assoc function

#10 @johnbillion
2 weeks ago

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

#11 @johnbillion
2 weeks ago

  • Keywords commit added

Pushed some formatting updates to the PR. Looking good.

#12 @johnbillion
2 weeks ago

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

In 49580:

General: Convert wp_array_get() to a "private" function and add tests.

This function may be promoted in the future if it's deemed useful enough.

Props dd32, jorgefilipecosta, Hareesh Pillai

Fixes #51720

#13 @jorgefilipecosta
2 weeks ago

Thank you all for the help on this ticket!

Note: See TracTickets for help on using tickets.