#51461 closed enhancement (fixed)
Update WordPress packages
Reported by: | isabel_brison | Owned by: | jorgefilipecosta |
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | 2nd-opinion has-patch |
Focuses: | Cc: |
Description
@wordpress npm packages need updating prior to 5.6 Beta 1. This ticket tracks the first round of updates. There will be a second round after the release of Gutenberg 9.2, just before 5.6 Beta 1.
Change History (17)
This ticket was mentioned in PR #573 on WordPress/wordpress-develop by tellthemachines.
4 years ago
#1
- Keywords has-patch added
This ticket was mentioned in PR #579 on WordPress/wordpress-develop by tellthemachines.
4 years ago
#2
Updates block-library
package and all related php
and json
files.
Trac ticket: https://core.trac.wordpress.org/ticket/51461
This ticket was mentioned in PR #585 on WordPress/wordpress-develop by jorgefilipecosta.
4 years ago
#3
#4
@
4 years ago
- Owner set to jorgefilipecosta
- Resolution set to fixed
- Status changed from new to closed
In 49135:
jorgefilipecosta commented on PR #585:
4 years ago
#5
@mcsf your feedback was applied.
#6
follow-up:
↓ 7
@
4 years ago
- Keywords needs-patch 2nd-opinion added; has-patch removed
- Resolution fixed deleted
- Status changed from closed to reopened
Is there a reason why an array.php
file was introduced for just one function? I think the function should be moved into wp-includes/functions.php instead.
#7
in reply to:
↑ 6
@
4 years ago
Replying to ocean90:
Is there a reason why an
array.php
file was introduced for just one function? I think the function should be moved into wp-includes/functions.php instead.
Yes, I had the same thought here. We already have a couple of array functions in wp-includes/functions.php
:
wp_array_slice_assoc()
wp_is_numeric_array()
It makes sense to move wp_array_get()
there as well.
This ticket was mentioned in PR #597 on WordPress/wordpress-develop by tellthemachines.
4 years ago
#8
- Keywords has-patch added; needs-patch removed
Addresses feedback on recent package update. Cc @ocean90 @SergeyBiryukov @jorgefilipecosta
Trac ticket: https://core.trac.wordpress.org/ticket/51461
#11
@
4 years ago
Just wanted to note that the new wp_array_get()
function seems.. weird, and I'm not entirely sure it's worth treating as a publicly available function, perhaps it should be marked internal-use? or skipped entirely?
In all cases, it's being used without making use of it's sub-array functionality, mostly replacing code similar to this:
isset( $block->supports['field'] ) ? $block->supports['field'] : false
In a PHP7+ world, wp_array_get( $block->supports, array( 'field' ), false )
could be replaced with $block->supports['field'] ?? false
(which seems far easier to read than this function, same as the isset() is easier to understand)
There's also an edge oddity around null values (that while not used in core, might present in others usage of it) such that wp_array_get( [ 'key' => null ], [ 'key' ], true )
returns true
as the key isn't considered set in the input. Perhaps that would be thought of as expected behaviour.
edit: had to add array syntax around the $path
var param in examples which I missed.
#12
@
4 years ago
I had the same thought when I saw it. It doesn't seems to follow the guideline about clever code.
I'd personally suggest removing it, and writing simple, descriptive isset()
statements like in Dion's example.
#13
@
4 years ago
Hi @dd32, @iandunn,
The function wp_array_get got introduced to be an equivalent of JavaScript lodash get https://lodash.com/docs/4.17.15#get.
The lodash get is very used on Gutenberg client-side and we have functions that need to work on both the client and the server. So in order for the code to be an almost direct translation of JavaScript to PHP, it seemed good to introduce an equivalent function in PHP.
The usages we have now in fact could easily be implemented using an alternative approach and they don't use the subarray functionality where the power of this function relies on.
But soon we will have in core code where the function with subarray functionality is needed https://github.com/WordPress/gutenberg/blob/ba5cecc8c82665ee7d89e36457e7d47de5d81131/lib/global-styles.php#L689 where even the path is not static but a variable itself.
I like the idea of marking the function as internal-use at least for now until the function proves useful in some cases.
Is there any guide on how to mark a function as internal-use?
This ticket was mentioned in PR #692 on WordPress/wordpress-develop by jorgefilipecosta.
4 years ago
#14
According to feedback received at https://core.trac.wordpress.org/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
Update @wordpress npm packages that don't require associated PHP changes. Subsequent PRs will deal with the remaining packages.
Trac ticket: https://core.trac.wordpress.org/ticket/51461