Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#59441 closed defect (bug) (fixed)

Use instanceof in block_has_support

Reported by: spacedmonkey's profile spacedmonkey Owned by: spacedmonkey's profile spacedmonkey
Milestone: 6.4 Priority: normal
Severity: normal Version: 5.8
Component: Editor Keywords: has-patch commit
Focuses: performance Cc:

Description

The function block_has_support can be called around 4000 times on a page load. The property_exists check, can be expensive. Replaces it with instanceof, is much faster.

Change History (6)

#1 @spacedmonkey
12 months ago

Example profile that saves around 4ms which is around 2.5% of server time.

https://blackfire.io/profiles/compare/c13c320b-88ec-43bf-a5fb-6d5902cda78e/graph

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


12 months ago
#2

  • Keywords has-patch added

This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.


12 months ago

#4 @spacedmonkey
12 months ago

  • Keywords commit added
  • Owner set to spacedmonkey
  • Status changed from new to assigned

#5 @spacedmonkey
12 months ago

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

In 56678:

Themes: Use instanceof in block_has_support.

In [50761], the block_has_support function was introduced. However, using property_exists within this function negatively impacted its performance. This commit replaces the property_exists function call with instanceof WP_Block_Type, resulting in improved performance.

Props mukesh27, gziolo, spacedmonkey.
Fixes #59441.

Note: See TracTickets for help on using tickets.