Make WordPress Core

Opened 7 months ago

Closed 7 months ago

Last modified 3 months ago

#59453 closed enhancement (fixed)

Replace property_exists call in block api with instanceof

Reported by: spacedmonkey's profile spacedmonkey Owned by: gziolo's profile gziolo
Milestone: 6.4 Priority: normal
Severity: normal Version: 5.8
Component: Editor Keywords: has-patch gutenberg-merge
Focuses: coding-standards Cc:

Description

Remove calls this in block functions

property_exists( $block_type, 'supports' ) 

with

$block_type instanceof WP_Block_Type

Change History (12)

This ticket was mentioned in PR #5308 on WordPress/wordpress-develop by @spacedmonkey.


7 months ago
#1

  • Keywords has-patch added

#2 @spacedmonkey
7 months ago

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

#3 @spacedmonkey
7 months ago

There are performance benefits and code quality to this improvement.

#4 @flixos90
7 months ago

@spacedmonkey Could you share some benchmarks or profiles here in regards to the performance impact?

#5 @gziolo
7 months ago

I'm not entirely sure how backporting works for these files, but it's worth emphasizing that the same code lives in the Gutenberg plugin in https://github.com/WordPress/gutenberg/tree/trunk/lib/block-supports. I'm sure these files aren't copied automatically, but if you agree on the changes, we will have to apply the same set of changes in the Gutenberg plugin. I can see how these changes would improve performance by using language constructs like instanceof and isset.

A separate discussion would be how to make it easier to sync code between WordPress core and Gutenberg for block supports.

#7 @spacedmonkey
7 months ago

  • Keywords gutenberg-merge added

#8 @spacedmonkey
7 months ago

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

In 56742:

Editor: Replace property_exists calls in block related functions with instanceof

Replace calls to property_exists with instanceof WP_Block_Type in block related functions. This change not only improves type safety but also enhances performance.

Follow on from [56678] and [56677].

Props gziolo, aristath, aaronrobertshaw, spacedmonkey.
Fixes #59453

#10 @kebbet
3 months ago

I think this changeset was introduced in 6.4, is that correct? Please milestone it accordingly @spacedmonkey, thanks!

Trying to clean up committed tickets from the Future release milestone.

#11 @spacedmonkey
3 months ago

This issue seems fixed. Closing.

#12 @spacedmonkey
3 months ago

  • Milestone changed from Future Release to 6.4
Note: See TracTickets for help on using tickets.