Make WordPress Core

Opened 11 months ago

Closed 10 months ago

Last modified 10 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:



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.


Change History (10)

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

11 months ago

  • Keywords has-patch has-unit-tests added

#2 @hellofromTonya
11 months ago

  • Keywords gutenberg-merge added

Adding keyword for backport tracking.

@spacedmonkey commented on PR #3902:

11 months ago

### Before

### After

Performance improvement 👍

@Mamaduka commented on PR #3902:

11 months ago

Updated the function name and added simple unit tests.

#5 @flixos90
10 months ago

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

#6 @flixos90
10 months ago

  • Focuses performance added

@Mamaduka commented on PR #3902:

10 months ago

Good catch. Thank you, @felixarntz!

@Mamaduka commented on PR #3902:

10 months ago

Thank you, @mukeshpanchal27!

#9 @flixos90
10 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.