Make WordPress Core

Opened 7 weeks ago

Closed 5 weeks ago

Last modified 5 weeks ago

#62291 closed enhancement (fixed)

Reuse block metadata in WP_Theme_JSON::get_valid_block_style_variations() for better performance

Reported by: mukesh27's profile mukesh27 Owned by: mukesh27's profile mukesh27
Milestone: 6.8 Priority: normal
Severity: normal Version: 6.6
Component: Editor Keywords: has-patch
Focuses: performance Cc:

Description

In WP_Theme_JSON::get_valid_block_style_variations(), the method was calling self::get_blocks_metadata() even though the metadata was already retrieved in the parent function. This update reuses the existing block metadata instead of calling it again.

A new optional parameter, $blocks_metadata, has been added to the function, allowing it to use pre-fetched metadata when available, improving efficiency.

Fewer self::get_blocks_metadata() calls mean faster processing, especially in themes with many blocks.

Attachments (2)

Before.png (75.4 KB) - added by mukesh27 7 weeks ago.
After.png (74.4 KB) - added by mukesh27 7 weeks ago.

Download all attachments as: .zip

Change History (10)

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


7 weeks ago
#1

  • Keywords has-patch added; needs-patch removed

@mukesh27
7 weeks ago

@mukesh27
7 weeks ago

@mukesh27 commented on PR #7586:


6 weeks ago
#2

Let me know if you need help backporting to the plugin.

Yes please if you have moment. Thanks

@ramonopoly commented on PR #7586:


5 weeks ago
#4

Is this ready to be committed? The Gutenberg backport PR is merged.

@mukesh27 commented on PR #7586:


5 weeks ago
#5

Is this ready to be committed? The Gutenberg backport PR is merged.

Yes. If you have moment then commit it.

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


5 weeks ago

#7 @ramonopoly
5 weeks ago

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

In 59359:

Performance: reuse block metadata in WP_Theme_JSON::get_valid_block_style_variations()

In WP_Theme_JSON::get_valid_block_style_variations(), the method was calling self::get_blocks_metadata() even though the metadata was already retrieved in the parent function. This update reuses the existing block metadata instead of calling it again.

A new optional parameter, $blocks_metadata, has been added to the function, allowing it to use pre-fetched metadata when available, improving efficiency.

Fewer self::get_blocks_metadata() calls mean faster processing, especially in themes with many blocks.

Props mukesh27, ramonopoly, aaronrobertshaw, flixos90.
Fixes #62291.

@ramonopoly commented on PR #7586:


5 weeks ago
#8

Committed in r59359 / 5ff971744e4b2d246c66f58d436cac5eff2a0662

Note: See TracTickets for help on using tickets.