WordPress.org

Make WordPress Core

Opened 13 months ago

Closed 13 months ago

Last modified 7 months 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 (15)

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


13 months 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
13 months ago

  • Description modified (diff)

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


13 months ago

#4 @johnbillion
13 months 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 13 months ago by johnbillion (previous) (diff)

#5 @jorgefilipecosta
13 months 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
13 months ago

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

#7 @hellofromTonya
13 months ago

  • Keywords has-unit-tests added

Tests were added yesterday.

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


13 months ago

#9 @Hareesh Pillai
13 months 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
13 months ago

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

#11 @johnbillion
13 months ago

  • Keywords commit added

Pushed some formatting updates to the PR. Looking good.

#12 @johnbillion
13 months 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
13 months ago

Thank you all for the help on this ticket!

#14 @SergeyBiryukov
7 months ago

In 50964:

Tests: Add missing tests for the _wp_array_get() function.

Follow-up to [49143], [49144], [49580].

Props jorgefilipecosta, johnbillion.
See #51461, #51720, #52625.

#15 @SergeyBiryukov
7 months ago

In 50970:

Tests: Remove trailing commas in function calls in _wp_array_get() tests.

This fixes parse errors on PHP 7.2 and lower versions.

Follow-up to [49143], [49144], [49580], [50964].

See #51461, #51720, #52625.

Note: See TracTickets for help on using tickets.