Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#51720 closed defect (bug) (fixed)

Make wp_array_get internal for now. Add tests to _wp_array_get;

Reported by: jorgefilipecosta's profile jorgefilipecosta Owned by: johnbillion's profile 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.


4 years ago
#1

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
4 years ago

  • Description modified (diff)

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


4 years ago

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

#5 @jorgefilipecosta
4 years 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
4 years ago

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

#7 @hellofromTonya
4 years ago

  • Keywords has-unit-tests added

Tests were added yesterday.

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


4 years ago

#9 @Hareesh Pillai
4 years 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
4 years ago

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

#11 @johnbillion
4 years ago

  • Keywords commit added

Pushed some formatting updates to the PR. Looking good.

#12 @johnbillion
4 years 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
4 years ago

Thank you all for the help on this ticket!

#14 @SergeyBiryukov
4 years 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
4 years 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.