WordPress/wp-includes
oandregal dafa13a0b9 Themes: improve performance of get_block_templates().
`get_block_templates()` is responsible for finding block templates that match a given search. The function receives a query parameter with the relevant metadata (slugs of the templates, areas of the template parts, etc) to find the user templates (database) and theme templates (file directory).

This function can be made more performant by changing how it works. Before this change, it processed all the block templates and discarded the ones that didn't match the query after it occurred. This commit makes it so it discards the templates that don't match the query before processing them. As a result, it only has to process the subset of templates that will be used, instead of all of them.

This change impacts any theme with block templates. TwentyTwentyThree reports a 15% improvement in Time To First Byte.

Props spacedmonkey, jorgefilipecosta, youknowriad, flixos90, mukesh27.
Fixes #57756.

Built from https://develop.svn.wordpress.org/trunk@55687


git-svn-id: http://core.svn.wordpress.org/trunk@55199 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-26 14:40:19 +00:00
..
assets Editor: Update @wordpress packages for 6.2 RC3. 2023-03-21 12:43:46 +00:00
block-patterns
block-supports Editor: Move variables to where used in wp_render_layout_support_flag. 2023-03-13 16:32:20 +00:00
blocks Editor: Update @wordpress packages for 6.2 RC2. 2023-03-14 15:45:47 +00:00
certificates
css Editor: Update @wordpress packages for 6.2 RC3. 2023-03-21 12:43:46 +00:00
customize Help/About: Avoid extra redirections on HelpHub Links. 2023-02-23 11:06:19 +00:00
fonts
html-api HTML API: Fix a case where updates are overlooked when seeking to earlier locations. 2023-04-21 13:32:25 +00:00
ID3 External Libraries: Update getID3 to version 1.9.22. 2022-10-04 02:08:11 +00:00
images General: Remove Windows Live Writer manifest file. 2023-04-04 14:56:22 +00:00
IXR Code Modernization: Use correct property in IXR_Message::tag_open(). 2023-01-20 01:36:10 +00:00
js Media: Render attachment custom fields for new uploads. 2023-04-12 23:44:22 +00:00
php-compat Code Modernization: Rename parameters that use reserved keywords in wp-includes/php-compat/readonly.php. 2022-12-08 19:31:17 +00:00
PHPMailer External Libraries: Upgrade PHPMailer to version 6.8.0. 2023-03-17 14:22:22 +00:00
pomo Code Modernization: Rename parameters that use reserved keywords in wp-includes/pomo/streams.php. 2022-12-12 20:21:12 +00:00
random_compat
Requests External Libraries: Update the Requests library to version 2.0.6. 2023-04-05 13:12:26 +00:00
rest-api Editor: Add selectors field to block type definition 2023-04-21 10:43:25 +00:00
SimplePie
sitemaps HTTP API: Fix request header inconsistencies. 2023-02-03 13:35:20 +00:00
sodium_compat Upgrade/Install: Update sodium_compat to v1.19.0. 2022-09-26 14:00:10 +00:00
style-engine Editor: Introduce minimum height dimensions block support. 2023-02-01 16:15:15 +00:00
Text
theme-compat Coding Standards: Various brace indentation corrections. 2022-11-26 21:01:17 +00:00
widgets Docs: Use third-person singular verbs in various function descriptions, as per docblocks standards. 2023-04-24 16:37:22 +00:00
admin-bar.php Toolbar: Update the URL for Documentation link in the admin bar. 2023-02-23 12:34:18 +00:00
atomlib.php
author-template.php Users: Use a separate variable for the post counts query in wp_list_authors(). 2023-03-01 15:39:27 +00:00
block-editor.php Editor: Correctly merge custom CSS into global styles 2023-03-01 11:43:20 +00:00
block-i18n.json
block-patterns.php Editor: Support the block_types and viewport_width props for remote patterns fetched from Pattern Directory. 2023-02-06 19:40:16 +00:00
block-template-utils.php Themes: improve performance of get_block_templates(). 2023-04-26 14:40:19 +00:00
block-template.php Themes: remove unused parameter in query for get_block_templates(). 2023-04-26 14:27:24 +00:00
blocks.php Editor: Add selectors field to block type definition 2023-04-21 10:43:25 +00:00
bookmark-template.php
bookmark.php Docs: Document default values for optional parameters in various DocBlocks. 2023-02-21 16:39:19 +00:00
cache-compat.php Cache API: Introduce wp_cache_supports() function. 2022-10-10 18:22:11 +00:00
cache.php Cache API: Introduce wp_cache_supports() function. 2022-10-10 18:22:11 +00:00
canonical.php Docs: Improve code comments in some sanitizing functions. 2023-02-15 13:06:21 +00:00
capabilities.php Coding Standards: Always use parentheses when instantiating an object. 2022-11-29 15:51:14 +00:00
category-template.php Docs: Use consistent format for the @return tags in _wp_object_name_sort_cb() and _wp_object_count_sort_cb(). 2023-02-04 15:18:16 +00:00
category.php
class-feed.php
class-http.php
class-IXR.php
class-json.php HTTP API: Fix request header inconsistencies. 2023-02-03 13:35:20 +00:00
class-oembed.php
class-phpass.php External Libraries: Prevent a PHP 8.1 deprecation notice in PasswordHash::gensalt_blowfish(). 2023-02-13 09:08:23 +00:00
class-phpmailer.php
class-pop3.php Mail: Check that set_time_limit() function is available before using it in class-pop3.php. 2023-02-11 12:43:22 +00:00
class-requests.php External Libraries: Update the Requests library to version 2.0.6. 2023-04-05 13:12:26 +00:00
class-simplepie.php HTTP API: Fix request header inconsistencies. 2023-02-03 13:35:20 +00:00
class-smtp.php
class-snoopy.php HTTP API: Fix request header inconsistencies. 2023-02-03 13:35:20 +00:00
class-walker-category-dropdown.php
class-walker-category.php
class-walker-comment.php
class-walker-nav-menu.php Privacy: Add rel="privacy-policy" to the Privacy Policy link. 2023-02-07 14:05:20 +00:00
class-walker-page-dropdown.php
class-walker-page.php
class-wp-admin-bar.php Code Modernization: Fix dynamic properties in WP_Admin_Bar. 2023-03-21 20:00:19 +00:00
class-wp-ajax-response.php
class-wp-application-passwords.php
class-wp-block-editor-context.php
class-wp-block-list.php
class-wp-block-parser.php Block Editor: Updated the WordPress packages to include Gutenberg 15.1.0 changes. 2023-02-07 07:04:52 +00:00
class-wp-block-pattern-categories-registry.php
class-wp-block-patterns-registry.php Docs: Document the inserter property in WP_Block_Patterns_Registry::register(). 2023-02-01 15:29:13 +00:00
class-wp-block-styles-registry.php
class-wp-block-supports.php Block editor: Add ID support to block wrapper attributes. 2023-02-06 15:24:16 +00:00
class-wp-block-template.php
class-wp-block-type-registry.php
class-wp-block-type.php Editor: Add selectors field to block type definition 2023-04-21 10:43:25 +00:00
class-wp-block.php Docs: Improve various globals documentation, as per documentation standards. 2022-11-23 21:30:13 +00:00
class-wp-comment-query.php Comments: Use wp_cache_get_multiple in WP_Comment_Query. 2023-03-29 10:20:20 +00:00
class-wp-comment.php Docs: Use third-person singular verbs in various function descriptions, as per docblocks standards. 2023-04-24 16:37:22 +00:00
class-wp-customize-control.php I18N: Mark screen reader strings as such with translator comments. 2023-02-07 17:10:21 +00:00
class-wp-customize-manager.php Help/About: Use the new /documentation/ URLs for HelpHub links in WordPress Admin. 2023-02-23 10:38:21 +00:00
class-wp-customize-nav-menus.php I18N: Mark screen reader strings as such with translator comments. 2023-02-07 17:10:21 +00:00
class-wp-customize-panel.php I18N: Mark screen reader strings as such with translator comments. 2023-02-07 17:10:21 +00:00
class-wp-customize-section.php I18N: Mark screen reader strings as such with translator comments. 2023-02-07 17:10:21 +00:00
class-wp-customize-setting.php
class-wp-customize-widgets.php I18N: Mark screen reader strings as such with translator comments. 2023-02-07 17:10:21 +00:00
class-wp-date-query.php Docs: Document the usage of $wpdb global in WP_Date_Query methods. 2022-11-08 13:29:16 +00:00
class-wp-dependencies.php Docs: Correct the type for _WP_Dependency::$src property. 2022-11-25 15:12:16 +00:00
class-wp-dependency.php Docs: Correct the type for _WP_Dependency::$src property. 2022-11-25 15:12:16 +00:00
class-wp-editor.php Coding Standards: Rename the $qtInit and $mceInit variables in _WP_Editors. 2023-04-12 09:43:21 +00:00
class-wp-embed.php Coding Standards: Rename $post_ID variable to $post_id in various files. 2023-02-19 15:05:22 +00:00
class-wp-error.php Docs: Document default values for optional parameters in various DocBlocks. 2023-02-21 16:39:19 +00:00
class-wp-fatal-error-handler.php Help/About: Use the new /documentation/ URLs for HelpHub links in WordPress Admin. 2023-02-23 10:38:21 +00:00
class-wp-feed-cache-transient.php
class-wp-feed-cache.php
class-wp-hook.php
class-wp-http-cookie.php
class-wp-http-curl.php Docs: Revise comments using “we” in various docblocks. 2023-04-11 22:06:22 +00:00
class-wp-http-encoding.php
class-wp-http-ixr-client.php
class-wp-http-proxy.php Docs: Align spelling with American English. 2022-10-21 21:12:14 +00:00
class-wp-http-requests-hooks.php External Libraries: Update Requests library to version 2.0.0. 2022-12-15 21:32:17 +00:00
class-wp-http-requests-response.php External Libraries: Update Requests library to version 2.0.0. 2022-12-15 21:32:17 +00:00
class-wp-http-response.php
class-wp-http-streams.php HTTP API: Correct the documentation for the https_ssl_verify and https_local_ssl_verify filters. 2023-01-13 14:22:12 +00:00
class-wp-http.php HTTP API: Add fragment support to WP_Http::make_absolute_url(). 2023-02-21 01:49:20 +00:00
class-wp-image-editor-gd.php
class-wp-image-editor-imagick.php Media: Add WP_Image_Editor_Imagick::set_imagick_time_limit() method. 2023-02-22 14:25:25 +00:00
class-wp-image-editor.php Media: ensure the wp_editor_set_quality filter consistently passes the correct output mime type. 2022-10-07 19:17:12 +00:00
class-wp-list-util.php General: Add more error checking to WP_List_Util::pluck(). 2023-02-25 10:59:22 +00:00
class-wp-locale-switcher.php Docs: Correct @since tag for WP_Locale_Switcher::$stack. 2023-02-08 17:08:21 +00:00
class-wp-locale.php I18N: Check that $wp_locale global is set before calling its methods. 2023-02-15 23:37:17 +00:00
class-wp-matchesmapregex.php
class-wp-meta-query.php Docs: Document default values for optional parameters in various DocBlocks. 2023-02-21 16:39:19 +00:00
class-wp-metadata-lazyloader.php Options, Meta APIs: Improve the lazy loading meta API to include current object id. 2023-03-29 10:50:18 +00:00
class-wp-network-query.php Cache API: Introduce new queries cache groups. 2023-03-10 16:30:03 +00:00
class-wp-network.php
class-wp-object-cache.php Docs: Fix typo in _validate_cache_id() description. 2023-03-14 16:55:19 +00:00
class-wp-oembed-controller.php Docs: Document the usage of globals in some functions. 2022-11-13 13:51:20 +00:00
class-wp-oembed.php Help/About: Use the new /documentation/ URLs for HelpHub links in WordPress Admin. 2023-02-23 10:38:21 +00:00
class-wp-paused-extensions-storage.php
class-wp-post-type.php Docs: Increase the specificity of various property documentation. 2022-09-26 22:10:16 +00:00
class-wp-post.php
class-wp-query.php Coding Standards: Use strict comparison where count() is involved. 2023-04-10 12:56:21 +00:00
class-wp-recovery-mode-cookie-service.php Security: Additional translations of salt default phrase. 2022-10-04 03:59:13 +00:00
class-wp-recovery-mode-email-service.php I18N: Introduce switch_to_user_locale(). 2023-01-30 10:27:16 +00:00
class-wp-recovery-mode-key-service.php Recovery Mode: Use PasswordHash API directly when validating keys. 2023-02-21 15:59:18 +00:00
class-wp-recovery-mode-link-service.php
class-wp-recovery-mode.php
class-wp-rewrite.php Coding Standards: Use strict comparison where count() is involved. 2023-04-10 12:56:21 +00:00
class-wp-role.php
class-wp-roles.php Role/Capability: Revert the newly added update_role function for 6.1. 2022-10-24 14:56:16 +00:00
class-wp-scripts.php I18N: Use correct default value for JavaScript translations path. 2022-09-28 22:19:10 +00:00
class-wp-session-tokens.php Code Modernization: Add AllowDynamicProperties attribute to all (parent) classes. 2022-09-12 15:47:14 +00:00
class-wp-simplepie-file.php
class-wp-simplepie-sanitize-kses.php
class-wp-site-query.php Cache API: Introduce new queries cache groups. 2023-03-10 16:30:03 +00:00
class-wp-site.php
class-wp-styles.php Script Loader: Prevent double space between attributes in WP_Styles class. 2022-09-28 14:59:10 +00:00
class-wp-tax-query.php Docs: Improve various globals documentation, as per documentation standards. 2022-11-23 21:30:13 +00:00
class-wp-taxonomy.php Docs: Improve various globals documentation, as per documentation standards. 2022-11-26 09:39:13 +00:00
class-wp-term-query.php Taxonomy: Always lazily load term meta. 2023-04-21 09:24:22 +00:00
class-wp-term.php
class-wp-text-diff-renderer-inline.php Code Modernization: Allow some parameters with reserved keywords in wp-includes/class-wp-text-diff-renderer-*.php. 2023-01-30 15:24:13 +00:00
class-wp-text-diff-renderer-table.php I18N: Mark screen reader strings as such with translator comments. 2023-02-07 17:10:21 +00:00
class-wp-textdomain-registry.php Docs: Use correct 6.2.0 @since version in multiple docblocks. 2023-02-15 22:56:20 +00:00
class-wp-theme-json-data.php Code Modernization: Add AllowDynamicProperties attribute to recently introduced classes. 2022-10-11 15:00:12 +00:00
class-wp-theme-json-resolver.php Editor: Ensure Global styles values are reset in the site editor. 2023-03-01 16:17:18 +00:00
class-wp-theme-json-schema.php
class-wp-theme-json.php Docs: Use correct 6.2.0 @since version in multiple docblocks. 2023-02-15 22:56:20 +00:00
class-wp-theme.php Themes: Account for a numeric theme directory in WP_Theme::__construct(). 2023-02-27 15:34:23 +00:00
class-wp-user-meta-session-tokens.php
class-wp-user-query.php Users: Change cache group from users-queries to user-queries. 2023-04-24 13:53:22 +00:00
class-wp-user-request.php
class-wp-user.php Coding Standards: Always use parentheses when instantiating an object. 2022-11-29 15:51:14 +00:00
class-wp-walker.php
class-wp-widget-factory.php
class-wp-widget.php Docs: Document default values for optional parameters in various DocBlocks. 2023-02-21 16:39:19 +00:00
class-wp-xmlrpc-server.php Coding Standards: Use strict comparison where trim() is involved. 2023-04-17 17:01:24 +00:00
class-wp.php Bootstrap/Load: Correct sending the X-Pingback header in WP::send_headers(). 2022-10-18 16:11:16 +00:00
class-wpdb.php Help/About: Use a consistent capitalization for "Support forums" links across WP Admin. 2023-02-28 12:48:23 +00:00
class.wp-dependencies.php
class.wp-scripts.php
class.wp-styles.php
comment-template.php Coding Standards: Use more meaningful variable names in various comment functions. 2023-04-19 14:40:19 +00:00
comment.php Coding Standards: Replace include_once with require_once for required files. 2023-04-09 11:57:22 +00:00
compat.php Coding Standards: Allow some parameters with reserved keywords in wp-includes/compat.php. 2023-01-25 01:40:12 +00:00
cron.php Coding Standards: Replace include_once with require_once for required files. 2023-04-09 11:57:22 +00:00
date.php
default-constants.php
default-filters.php Users: Cache database queries within WP_User_Query class. 2023-04-18 11:50:27 +00:00
default-widgets.php
deprecated.php Coding Standards: Use strict comparison where substr() is involved. 2023-04-16 10:48:22 +00:00
embed-template.php
embed.php
error-protection.php
feed-atom-comments.php Coding Standards: Various brace indentation corrections. 2022-11-26 21:01:17 +00:00
feed-atom.php
feed-rdf.php
feed-rss2-comments.php Coding Standards: Rename $comment_ID variable to $comment_id in various files. 2023-02-12 18:08:21 +00:00
feed-rss2.php
feed-rss.php
feed.php
formatting.php Coding Standards: Use strict comparison where strtolower() is involved. 2023-04-22 15:19:22 +00:00
functions.php Coding Standards: Use strict comparison where count() is involved. 2023-04-10 12:56:21 +00:00
functions.wp-scripts.php Docs: Use third-person singular verbs for Script Loader related function descriptions, as per docblocks standards. 2023-01-15 14:57:13 +00:00
functions.wp-styles.php Docs: Use third-person singular verbs for Script Loader related function descriptions, as per docblocks standards. 2023-01-15 14:57:13 +00:00
general-template.php Coding Standards: Use strict comparison in wp-admin/includes/class-wp-site-icon.php. 2023-04-23 04:02:18 +00:00
global-styles-and-settings.php Editor: Add support for custom CSS in global styles. 2023-02-02 18:52:17 +00:00
http.php Coding Standards: Use strict comparison in wp-includes/http.php. 2023-04-13 15:43:21 +00:00
https-detection.php General: Remove Windows Live Writer manifest file. 2023-04-04 14:56:22 +00:00
https-migration.php
kses.php Coding Standards: Use strict comparison where strtolower() is involved. 2023-04-22 15:19:22 +00:00
l10n.php I18N: Check that $wp_locale global is set before calling its methods. 2023-02-15 23:37:17 +00:00
link-template.php Cache API: Introduce new queries cache groups. 2023-03-10 16:30:03 +00:00
load.php Users: Change cache group from users-queries to user-queries. 2023-04-24 13:53:22 +00:00
locale.php
media-template.php Media: improve display of cropped image in media editor. 2023-03-07 04:47:22 +00:00
media.php Media: Enhance logic to determine LCP image in block themes and avoid lazy-loading it. 2023-02-13 18:34:17 +00:00
meta.php Docs: Document default values for optional parameters in various DocBlocks. 2023-02-21 16:39:19 +00:00
ms-blogs.php Users: Change cache group from users-queries to user-queries. 2023-04-24 13:53:22 +00:00
ms-default-constants.php
ms-default-filters.php Posts, Post Types: Pass the post object to _update_posts_count_on_delete(). 2023-02-24 01:23:20 +00:00
ms-deprecated.php Docs: Improve various globals documentation, as per documentation standards. 2022-12-09 11:54:13 +00:00
ms-files.php
ms-functions.php Users: Cache database queries within WP_User_Query class. 2023-04-18 11:50:27 +00:00
ms-load.php Help/About: Use the new /documentation/ URLs for HelpHub links in WordPress Admin. 2023-02-23 10:38:21 +00:00
ms-network.php Networks and Sites: Revert the use of the metadata API for *_network_options functions. 2022-10-18 18:16:16 +00:00
ms-settings.php
ms-site.php Cache API: Introduce new queries cache groups. 2023-03-10 16:30:03 +00:00
nav-menu-template.php Coding Standards: Replace strval() with (string) type casting in wp_nav_menu(). 2023-02-16 00:04:21 +00:00
nav-menu.php Docs: Use correct 6.2.0 @since version in multiple docblocks. 2023-02-15 22:56:20 +00:00
option.php Options, Meta APIs: Add a filter to allow the shortcut return to wp_load_alloptions function. 2023-02-07 12:49:17 +00:00
pluggable-deprecated.php
pluggable.php General: Don't pass $action to wp_get_session_token() in wp_create_nonce(). 2023-04-25 14:57:23 +00:00
plugin.php
post-formats.php Docs: Document default values for optional parameters in various DocBlocks. 2023-02-21 16:39:19 +00:00
post-template.php Coding Standards: Use strict comparison where strlen() is involved. 2023-04-15 12:11:24 +00:00
post-thumbnail-template.php Media: Allow for customization of lazy-loading featured images. 2023-01-19 07:34:14 +00:00
post.php Coding Standards: Use strict comparison where strtolower() is involved. 2023-04-22 15:19:22 +00:00
query.php Cache API: Introduce new queries cache groups. 2023-03-10 16:30:03 +00:00
registration-functions.php
registration.php
rest-api.php Docs: Miscellaneous improvements and corrections to docblocks. 2023-02-07 21:21:18 +00:00
revision.php Revisions: Remove an unnecessary call to _doing_it_wrong() and corresponding new text string from the implementation of the new wp_save_post_revision_revisions_before_deletion filter. 2023-02-22 20:49:20 +00:00
rewrite.php Code Modernization: Rename parameters that use reserved keywords in wp-includes/rewrite.php. 2022-12-15 11:03:11 +00:00
robots-template.php
rss-functions.php
rss.php Docs: Fix a typo in wp-includes/rss.php inline comments. 2023-04-10 19:31:18 +00:00
script-loader.php Script Loader: Improve code style and readability in _wp_normalize_relative_css_links(). 2023-04-21 03:13:22 +00:00
session.php
shortcodes.php Code Modernization: Rename parameters that use reserved keywords in phpunit/tests/shortcode.php. 2023-01-23 16:35:12 +00:00
sitemaps.php
spl-autoload-compat.php
style-engine.php
taxonomy.php Taxonomy: Always lazily load term meta. 2023-04-21 09:24:22 +00:00
template-canvas.php
template-loader.php
template.php Coding Standards: Use strict comparison where count() is involved. 2023-04-10 12:56:21 +00:00
theme-i18n.json Editor: Introduce spacing presets in global style properties. 2022-09-21 11:43:13 +00:00
theme-templates.php Coding Standards: Rename $post_ID variable to $post_id in various files. 2023-02-19 15:05:22 +00:00
theme.json Themes: Add 3 and update 2 shadow presets in theme.json. 2023-02-22 16:00:21 +00:00
theme.php Coding Standards: Use strict comparison where strtolower() is involved. 2023-04-22 15:19:22 +00:00
update.php Coding Standards: Replace include_once with require_once for required files. 2023-04-09 11:57:22 +00:00
user.php Users: Cache database queries within WP_User_Query class. 2023-04-18 11:50:27 +00:00
vars.php Help/About: Use the new /documentation/ URLs for HelpHub links in WordPress Admin. 2023-02-23 10:38:21 +00:00
version.php Themes: improve performance of get_block_templates(). 2023-04-26 14:40:19 +00:00
widgets.php Help/About: Avoid extra redirections on HelpHub Links. 2023-02-23 11:06:19 +00:00
wp-db.php
wp-diff.php