Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#59441 closed defect (bug) (fixed)

Use instanceof in block_has_support

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

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
3 years 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.


3 years ago
#2

  • Keywords has-patch added

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


3 years ago

#4 @spacedmonkey
3 years ago

  • Keywords commit added
  • Owner set to spacedmonkey
  • Status newassigned

#5 @spacedmonkey
3 years ago

  • Resolutionfixed
  • Status assignedclosed

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.