Repository navigation
Prevented sign-up fatal errors on empty response - #1210
Conversation
There was a problem hiding this comment.
🟢 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 withCall to a member function get_error_code() on false. This shows the tests detect the fix. - A source trace found no other path where
falsereaches aWP_Errormethod inregister_service(). - The
WP_Errorresponses 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
| 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'] ); | ||
| } |
There was a problem hiding this comment.
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.
|
🎉 This PR is included in version 4.2.18 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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 validWP_Errorinstances and returns the plain “Error creating account.” response withcode: errorwhen the API returnsfalse, restoring the behavior from version 3.11.3 and preventing fatal errors.Closes #1200
Other information: