[wp-trac] [WordPress Trac] #56707: `register_block_type`'s `editor_script` handle fails if it is an array.

WordPress Trac noreply at wordpress.org
Mon Oct 24 14:30:34 UTC 2022


#56707: `register_block_type`'s `editor_script` handle fails if it is an array.
-------------------------------------------------+-------------------------
 Reporter:  nendeb55                             |       Owner:  Bernhard
                                                 |  Reiter
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  6.1
Component:  Editor                               |     Version:  6.1
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  needs-testing has-testing-info dev-  |     Focuses:
  feedback has-patch has-unit-tests              |
-------------------------------------------------+-------------------------

Comment (by Bernhard Reiter):

 In [changeset:"54671" 54671]:
 {{{
 #!CommitTicketReference repository="" revision="54671"
 Blocks: Allow arrays for deprecated asset types in block registration.

 In `register_block_type`, continue to allow passing arrays as the
 `editor_script`, `script`, `view_script`, `editor_style`, and `style`
 arguments. Note that those fields were soft-deprecated in favor of their
 `_handles` counterparts in [54155], which would allow specifying multiple
 items. At the same time, the deprecated fields were limited to `string` or
 `null`.

 However, this broke existing code that passed an array as one of those
 arguments. For backwards compatibility, this change thus restores the
 previous behavior. It is implemented in `WP_Block_Type` as a pair of
 `__get()` and `__set()` methods that wrap around the corresponding
 `_handles` members, which are arrays of strings.

 It also affects the REST API endpoint for block types. The latter’s schema
 has never allowed for anything other than `string` or `null` for any of
 those fields. For this reason, it now returns the first element of the
 array stored in the corresponding `_handles` member in `WP_Block_Type`.

 Follow-up [54155].
 Props nendeb55, costdev, gziolo, spacedmonkey, mukesh27, sergeybiryukov,
 audrasjb.
 Merges [54670] to the 6.1 branch.
 Fixes #56707.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56707#comment:29>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list