Make WordPress Core

Opened 14 months ago

Closed 14 months ago

Last modified 14 months ago

#57547 closed enhancement (fixed)

Remove get_default_block_editor_settings from theme JSON resolver

Reported by: mamaduka's profile Mamaduka Owned by: flixos90's profile flixos90
Milestone: 6.2 Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch has-unit-tests gutenberg-merge
Focuses: performance Cc:

Description

Context:

The issue, is that the function get_default_block_editor_settings is called. This
function returns an array of data, including lots of information needed for the
editor. But in this context, json resolved is getting lots of data is that is never
used. As this method is call 200-500 times per page load, it results in all these
calls to get_option, is_rtl and get_allowed_mime_types, data is never used. This
functions have serious overhead, as all of them have filters and some even database
queries attached to them. As this function is called on the front end, this results
in 11-15% of extra page load.

See https://github.com/WordPress/gutenberg/pull/46112

Change History (10)

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


14 months ago
#1

  • Keywords has-patch has-unit-tests added

#2 @hellofromTonya
14 months ago

  • Keywords gutenberg-merge added

Adding keyword for backport tracking.

@spacedmonkey commented on PR #3902:


14 months ago
#3

### Before

https://i0.wp.com/user-images.githubusercontent.com/237508/214524028-08195acc-0ab8-4053-a001-ff0eb26c42ca.png

### After
https://i0.wp.com/user-images.githubusercontent.com/237508/214523986-a55874e5-921e-43e0-94b0-a624d33cc7ed.png

Performance improvement 👍

@Mamaduka commented on PR #3902:


14 months ago
#4

Updated the function name and added simple unit tests.

#5 @flixos90
14 months ago

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

#6 @flixos90
14 months ago

  • Focuses performance added

@Mamaduka commented on PR #3902:


14 months ago
#7

Good catch. Thank you, @felixarntz!

@Mamaduka commented on PR #3902:


14 months ago
#8

Thank you, @mukeshpanchal27!

#9 @flixos90
14 months ago

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

In 55146:

Themes: Avoid unnecessary database queries from get_default_block_editor_settings() in WP_Theme_JSON_Resolver::get_theme_data().

The get_default_block_editor_settings() function included several pieces of data that are irrelevant for the purpose that WP_Theme_JSON_Resolver was calling it for, yet resulted in three database queries on page load that can be avoided.

This changeset introduces a new function get_classic_theme_supports_block_editor_settings() to takes responsibility of only the data needed in WP_Theme_JSON_Resolver, which now uses that function. This leads to a reduction of database queries and accordingly a performance improvement.

Props mamaduka, spacedmonkey, oandregal, flixos90, audrasjb, mukesh27.
Fixes #57547.

Note: See TracTickets for help on using tickets.