fix: auto-save API key and guard JSON output - #5
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the MyParcel OpenCart admin UX by auto-saving settings after a successful API key test and by preventing non-fatal PHP output from corrupting JSON/PDF responses for AJAX and downloads.
Changes:
- Add
OpenCartCompatibility::guardJsonOutput()to suppress non-fatal PHP notice/warning output in JSON/PDF endpoints. - Auto-submit the module settings form after a successful API key validation to avoid a separate manual save step.
- Update localized “save first” messaging to reflect the new auto-save behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| plugin/extension/myparcel/src/Support/OpenCartCompatibility.php | Introduces output-guarding helper for JSON/PDF responses via error/display settings. |
| plugin/extension/myparcel/admin/view/template/module/myparcel.twig | Auto-submits the settings form after a successful API key test. |
| plugin/extension/myparcel/admin/language/nl-nl/module/myparcel.php | Updates UI copy describing auto-save after key test. |
| plugin/extension/myparcel/admin/language/it-it/module/myparcel.php | Updates UI copy describing auto-save after key test. |
| plugin/extension/myparcel/admin/language/en-gb/module/myparcel.php | Updates UI copy describing auto-save after key test. |
| plugin/extension/myparcel/admin/controller/shipment/myparcel.php | Applies output guard to JSON/PDF shipment endpoints. |
| plugin/extension/myparcel/admin/controller/module/myparcel.php | Applies output guard to module save/key-check/import endpoints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * corrupts the admin AJAX handling. Non-fatal noise goes to the PHP error | ||
| * log instead; anything else follows the normal error route. | ||
| */ | ||
| public static function guardJsonOutput(): void |
| feedback.innerHTML = '<span class="text-success"><i class="fa-solid fa-circle-check"></i> ' + myparcelText.valid + info + '</span>'; | ||
| // Save right away so the carrier import works without a separate save | ||
| // step; OpenCart's ajax form binding shows its own confirmation. | ||
| document.getElementById('form-module').requestSubmit(); |
Comment on lines
+27
to
+39
| ini_set('display_errors', '0'); | ||
|
|
||
| set_error_handler(static function (int $code, string $message, string $file, int $line): bool { | ||
| $nonFatal = [E_DEPRECATED, E_USER_DEPRECATED, E_NOTICE, E_USER_NOTICE, E_WARNING, E_USER_WARNING]; | ||
|
|
||
| if (!in_array($code, $nonFatal, true)) { | ||
| return false; | ||
| } | ||
|
|
||
| error_log(sprintf('[MyParcel] PHP %d: %s in %s on line %d', $code, $message, $file, $line)); | ||
|
|
||
| return true; | ||
| }); |
myparcel-bot Bot
added a commit
that referenced
this pull request
Aug 5, 2026
## [1.0.0-beta.2](v1.0.0-beta.1...v1.0.0-beta.2) (2026-08-05) ### 🐛 Bug Fixes * auto-save API key and guard JSON output ([#5](#5)) ([33f1006](33f1006))
|
🎉 This PR is included in version 1.0.0-beta.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
A successful API key test now saves the settings automatically, so the carrier import works without a separate save step. JSON and PDF endpoints suppress non-fatal PHP notice output that OpenCart's error handler would otherwise echo into the response body, which showed a false 'Could not import carrier configuration' error while the import succeeded.