Ensured dynamic block renderer class exists before instantiation - #2966
Open
girishpanchal30 wants to merge 3 commits into
Open
Ensured dynamic block renderer class exists before instantiation#2966girishpanchal30 wants to merge 3 commits into
girishpanchal30 wants to merge 3 commits into
Conversation
Contributor
Bundle Size Diff
|
Contributor
|
Plugin build for 5e6da55 is ready 🛎️!
|
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents fatal errors when a dynamic block renderer class is unavailable by falling back to metadata registration.
Changes:
- Guards renderer instantiation with
class_exists(). - Adds regression tests for missing and unreadable renderer files.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
inc/class-registration.php |
Checks renderer availability before instantiation. |
tests/test-registration.php |
Tests unavailable renderer scenarios. |
Suppressed comments (1)
tests/test-registration.php:198
- When registration throws, this test exits before unregistering its temporary autoloader. That leaves global process state behind and can affect later tests; unregister it in a
finallyblock.
$this->register_blocks_with_captcha_renderer( $class );
spl_autoload_unregister( $loader );
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
E2E TestsPlaywright Test Status: See serial and parallel matrix jobs Performance ResultsserverResponse: {"q25":433.3,"q50":463.6,"q75":480.5,"cnt":10}, firstPaint: {"q25":1403.6,"q50":1728.15,"q75":1820.3,"cnt":10}, domContentLoaded: {"q25":3793.5,"q50":3825.55,"q75":3847.2,"cnt":10}, loaded: {"q25":3795.3,"q50":3827.5,"q75":3849.3,"cnt":10}, firstContentfulPaint: {"q25":4319.3,"q50":4372.8,"q75":4399.6,"cnt":10}, firstBlock: {"q25":15167.1,"q50":15350.1,"q75":15598.2,"cnt":10}, type: {"q25":26.44,"q50":32.03,"q75":34.22,"cnt":10}, typeWithoutInspector: {"q25":25.32,"q50":27.2,"q75":27.6,"cnt":10}, typeWithTopToolbar: {"q25":37.47,"q50":41.64,"q75":47.67,"cnt":10}, typeContainer: {"q25":18.09,"q50":19.14,"q75":20.62,"cnt":10}, focus: {"q25":145.77,"q50":150.53,"q75":158.13,"cnt":10}, inserterOpen: {"q25":51.14,"q50":54.52,"q75":57.41,"cnt":10}, inserterSearch: {"q25":19.1,"q50":20.54,"q75":21.31,"cnt":10}, inserterHover: {"q25":6.24,"q50":6.69,"q75":7.29,"cnt":20}, loadPatterns: {"q25":1910.95,"q50":1922.67,"q75":1975.08,"cnt":10}, listViewOpen: {"q25":269.22,"q50":277.97,"q75":283.43,"cnt":10} |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
tests/test-registration.php:117
- This replaces the test suite's existing error handler, and returning
falsefor non-matching errors invokes PHP's internal handler rather than delegating to the suite. Consequently, unrelated warnings raised anywhere inregister_blocks()can stop failing these tests and create false positives. Preserve the prior handler and forward every error except the expected failed include.
set_error_handler(
function ( $error_level, $message ) {
return E_WARNING === $error_level && false !== strpos( $message, 'renderer.php' );
}
);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2943
Summary
Checked dynamic blocks for class existence before instantiating them. This prevents fatal errors when a block is registered but the class is not available.
Checklist before the final review