Skip to content

Handled WP Error responses to prevent fatal - #4595

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

Handled WP Error responses to prevent fatal#4595
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/4559

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Summary

Handled WP_Error in rest_request_after_callbacks filter callbacks to prevent fatal errors when the response is an error. This ensures that the code only attempts to modify the response if it is a valid WP_REST_Response object.

Check before Pull Request is ready:

Closes #4559

@pirate-bot

pirate-bot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Plugin build for d1dde77 is ready 🛎️!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds WP_Error pass-through handling to Neve’s Elementor REST response filters and introduces unit tests to validate both error and success behavior.

Changes:

  • Return early when Elementor REST filter callbacks receive a WP_Error.
  • Update PHPDoc to reflect WP_REST_Response|\WP_Error inputs/outputs.
  • Add PHPUnit tests covering WP_Error pass-through and palette color merging.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/test-elementor-compatibility.php Adds unit tests for Elementor compatibility REST filtering behavior.
inc/compatibility/elementor.php Adds WP_Error early returns and updates docblocks for REST filter callbacks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test-elementor-compatibility.php Outdated
Comment thread tests/test-elementor-compatibility.php Outdated
Comment thread tests/test-elementor-compatibility.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown

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 1 comment.

Suppressed comments (1)

inc/compatibility/elementor.php:197

  • The REST route string is hard-coded here while the test introduces a route constant. Consider defining a class-level constant for /elementor/v1/globals (and reusing it in both picker and front-end methods) to avoid route drift and reduce duplication.
		$route = $request->get_route();

		if ( $route !== '/elementor/v1/globals' ) {

Comment thread tests/test-elementor-compatibility.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown

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-elementor-compatibility.php:39

  • Tests are reaching into a private property via reflection, which is brittle (renaming/typing changes to custom_global_colors will break tests even if public behavior is unchanged). Consider adding a small, test-friendly seam in the production class (e.g., a constructor parameter, protected setter, or dedicated reset method used only in tests) so the tests can set up state without reflection.
	private function get_elementor_compat() {
		$elementor = new \Neve\Compatibility\Elementor();

		$custom_colors = new ReflectionProperty( $elementor, 'custom_global_colors' );
		$custom_colors->setAccessible( true );
		$custom_colors->setValue( $elementor, [] );

		return $elementor;
	}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Elementor globals REST filter crashes when response is WP_Error

4 participants