Skip to content

fix: auto-save API key and guard JSON output - #5

Merged
NabDevs merged 1 commit into
mainfrom
fix/api-key-flow
Aug 5, 2026
Merged

fix: auto-save API key and guard JSON output#5
NabDevs merged 1 commit into
mainfrom
fix/api-key-flow

Conversation

@NabDevs

@NabDevs NabDevs commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI lite review requested due to automatic review settings August 5, 2026 08:32
@NabDevs
NabDevs merged commit 33f1006 into main Aug 5, 2026
6 of 7 checks passed
@NabDevs
NabDevs deleted the fix/api-key-flow branch August 5, 2026 08:34

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

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))
@myparcel-bot

myparcel-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0-beta.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Development

Successfully merging this pull request may close these issues.

2 participants