Skip to content

Prevented sign-up fatal errors on empty response - #1210

Merged
pirate-bot merged 1 commit into
developmentfrom
bugfix/1200
Oct 29, 2026
Merged

pirate-bot merged 1 commit into
developmentfrom
bugfix/1200

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

Fixed Optimole account registration failures by introducing register_error_response() to safely handle unsuccessful API responses. The helper reads error codes and messages only from valid WP_Error instances and returns the plain “Error creating account.” response with code: error when the API returns false, restoring the behavior from version 3.11.3 and preventing fatal errors.

Closes #1200

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@pirate-bot

Copy link
Copy Markdown
Collaborator

Plugin build for 8e82cd2 is ready 🛎️!

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟢 Approved

This approves the fix, and the note asks whether one new test is meant as a guard for unchanged code.

Validation details
  • Files reviewed: 2/2 changed files.
  • The new test file passed at HEAD with PHP 8.3.36, WordPress 7.1.4 and PHPUnit 9.6.22: OK (8 tests, 22 assertions).
  • With the old inc/rest.php, five cases failed with Call to a member function get_error_code() on false. This shows the tests detect the fix.
  • A source trace found no other path where false reaches a WP_Error method in register_service().
  • The WP_Error responses match the old output exactly.
Untested areas
  • The test runs above have no harness run record. Their logs were kept in the sandbox.

🤖 Automated review · run code-review-agent_6ae2f80c200077.76263237.


🤖 Review agent — review posted ✅ on 8e82cd23 · approved · 0 findings · 9 min

Run code-review-agent_6ae2f80c200077.76263237 · trail

Comment on lines +147 to +153
public function test_registered_email_keeps_its_code(): void {
$this->reply = self::reply( 400, '{"code":400,"error":"This email address is already registered."}' );

$data = $this->register();

$this->assertSame( 'email_registered', $data['code'] );
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

note This test covers only the email_registered branch of register_service(). This change does not touch that branch. In a sandbox run, the test also passed with the old inc/rest.php, so it cannot catch a regression of this fix. Is it meant as a guard for the email branch? If yes, it is safe to keep. If it was meant to test the fix, it tests nothing and should be removed.

@pirate-bot
pirate-bot merged commit 3e2badb into development Oct 29, 2026
13 checks passed
@pirate-bot
pirate-bot deleted the bugfix/1200 branch October 29, 2026 14:01
@pirate-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 4.2.18 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pirate-bot pirate-bot added the released Indicate that an issue has been resolved and released in a particular version of the product. label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Indicate that an issue has been resolved and released in a particular version of the product.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants