Skip to content

Ensured dynamic block renderer class exists before instantiation - #2966

Open
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/2943
Open

Ensured dynamic block renderer class exists before instantiation#2966
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/2943

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

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

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.
  • PR is following the best practices

@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Aug 6, 2026
@pirate-bot

Copy link
Copy Markdown
Contributor

Bundle Size Diff

Package Old Size New Size Diff
Animations 178.33 KB 178.33 KB 0 B (0.00%)
Blocks 1.65 MB 1.65 MB 0 B (0.00%)
CSS 7.83 KB 7.83 KB 0 B (0.00%)
Dashboard 172.49 KB 172.49 KB 0 B (0.00%)
Onboarding 68.14 KB 68.14 KB 0 B (0.00%)
Export Import 4.73 KB 4.73 KB 0 B (0.00%)
Pro 439.82 KB 439.82 KB 0 B (0.00%)

@pirate-bot

pirate-bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Plugin build for 5e6da55 is ready 🛎️!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 finally block.
		$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.

Comment thread tests/test-registration.php Outdated
Comment thread tests/test-registration.php Outdated
Comment thread tests/test-registration.php Outdated
@pirate-bot

pirate-bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

E2E Tests

Playwright Test Status: See serial and parallel matrix jobs

Performance Results serverResponse: {"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}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 false for non-matching errors invokes PHP's internal handler rather than delegating to the suite. Consequently, unrelated warnings raised anywhere in register_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' );
 			}
		);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-checklist-complete The Pull Request checklist is complete. (automatic label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants