Repository navigation
Blocks: Preserve pre-rendered content when generating preset styles - #14615
salvatorecorsi wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
When an earlier
pre_render_blockfilter returns cached HTML,'', or'0',_wp_add_block_level_preset_styles()replaces that value withnull. WordPress then renders the block instead of honoring the earlier short-circuit.Return the incoming
$pre_renderfrom all three exits and document thestring|nullreturn type. Preset CSS generation and enqueueing still run when the block supports settings and has presets, including when its markup was provided by an earlier filter. Anullinput continues through normal rendering.Trac ticket: https://core.trac.wordpress.org/ticket/59551
Companion Gutenberg change: WordPress/gutenberg#85260
This follows the ticket reported by danieliser and the pass-through approach discussed by jeremyfelt and pbiron. The remaining change concerns the preset-styles callback. Element support already uses
render_block_data, following its migration in WordPress 6.6.Reproduction
'<p>Cached paragraph</p>'and'0'. The exact replacement should be returned.Validation
The regression tests use a registered dynamic block, the real
serialize_block()/do_blocks()filter chain, and renderer/filter callback counts. Twelve cases cover unsupported blocks, supported blocks without settings, and blocks with real palette presets, each with empty string, string zero, cached HTML, andnull. The enqueued stylesheet callbacks verify that preset variables and classes are still emitted. The tests restore their owned filter, style-hook snapshots, and block registration.e46ac23b14711601e6cb17aafe63af6673c03591: 12 tests, 35 assertions, nine expected failures and no errors. All threenullcontrols passed, including actual preset CSS emission.block-supportsPHPUnit group: 511 tests and 741 assertions passed.npm run buildpassed. The builtsettings.phpmatches the reviewed source byte-for-byte.Validation used Windows, PHP 8.3.28, PHPUnit 9.6.38 and an isolated MariaDB test database. PHPUnit was executed through a local runner that serializes access to this disposable database. The checkout-local commands were:
PHPUnit reported a deprecated XML configuration schema warning. The successful build emitted Node deprecation and webpack asset-size/performance warnings. These warnings remain visible; no configuration, baseline or suppression was changed to hide them. The full PHPUnit suite, multisite and Docker-based tests were not run. Gutenberg's results are recorded separately in the companion PR.
Use of AI Tools
AI assistance: Yes
Tool(s): OpenAI Codex
Used for: Issue investigation, implementation, regression tests, validation, and this PR description. A separate Codex agent independently reviewed the implementation and tests and read the validation evidence. No human review by the account owner is claimed; contributor and maintainer review is requested.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.