Skip to content

Seed the per notification merchant emails on install - #163

Draft
boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:fix/seed-merchant-emails-on-install-34784
Draft

boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:fix/seed-merchant-emails-on-install-34784

Conversation

@boo-code

@boo-code boo-code commented Sep 5, 2026

Copy link
Copy Markdown
Questions Answers
Description? install() turns on the three merchant notifications and then writes the shop email into MA_MERCHANT_MAILS, the 1.6 era key. Since 2.4.0 the configuration form reads and writes one key per notification — MA_MERCHANT_ORDER_EMAILS, MA_MERCHANT_OOS_EMAILS, MA_RETURN_SLIP_EMAILS — and upgrade/upgrade-2.4.0.php migrates the old value into them. A fresh install never runs that upgrade, so the module lands with all three notifications enabled and no address in any field the form uses, and the very first save answers with three "Please enter one (or more) email address" errors before the merchant has touched anything. The three keys are now seeded from PS_SHOP_EMAIL alongside the legacy one, and uninstall() removes them: it dropped only the legacy key and left the three behind on every uninstall.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes PrestaShop/PrestaShop#34784
How to test? Install the module on a fresh shop, go to Module Manager > Email alerts > Configure and press Save without changing anything. Before this change the page answers with three "Please enter one (or more) email address" errors; after it the fields are pre-filled with the shop email and the save succeeds. For the second half: uninstall the module and check ps_configuration — no MA_* row should remain.

Measured

On a shop where the module was installed from upstream, before touching anything:

MA_MERCHANT_MAILS    = pub@prestashop.com     <- seeded by install(), legacy key
MA_MERCHANT_OOS      = 1
MA_MERCHANT_ORDER    = 1
MA_RETURN_SLIP       = 1
MA_MERCHANT_ORDER_EMAILS   -- absent
MA_MERCHANT_OOS_EMAILS     -- absent
MA_RETURN_SLIP_EMAILS      -- absent

Three notifications on, and the three keys postProcess() validates and saves do not exist. postProcess() reports Please enter one (or more) email address … for each flag that is on with an empty field, which is why the first save fails on a untouched install.

Real install cycle with the patched module (bin/console prestashop:module uninstall then install):

MA_MERCHANT_OOS_EMAILS   = pub@prestashop.com
MA_MERCHANT_ORDER_EMAILS = pub@prestashop.com
MA_RETURN_SLIP_EMAILS    = pub@prestashop.com

The uninstall half was checked against a control, with the keys present in both runs:

patched   uninstall -> per-type email keys left behind: 0
unpatched uninstall -> MA_MERCHANT_OOS_EMAILS, MA_MERCHANT_ORDER_EMAILS, MA_RETURN_SLIP_EMAILS all survive

PHPStan through the core config, comparing upstream/dev against the branch: 22 errors both ways, so the change adds none.

Not changed

Existing installs are left alone. Their three fields are whatever the merchant last saved, and re-seeding them on upgrade would silently restore an address a merchant may have removed on purpose. The error message already tells them which notification is missing an address.

The workaround circulating on the issue — adding a trailing comma — is unrelated: the delimiter is , and explode(',', 'a@b.com') already yields one valid address, so a single email without a comma saves fine once the field is not empty.

install() set the three merchant notification flags and then wrote the shop
email into MA_MERCHANT_MAILS, the 1.6 era key. Since 2.4.0 the configuration
form reads and writes one key per notification, and upgrade-2.4.0.php migrates
the old value into them - but a fresh install never runs that upgrade. So the
module installs with New order, Out of stock and Return slip all enabled and no
address in any of the fields the form uses, and the first save answers with
three "Please enter one (or more) email address" errors before the merchant has
touched anything.

The three keys are now seeded from PS_SHOP_EMAIL alongside the legacy one, and
uninstall() removes them - it dropped only the legacy key, leaving the three
behind on every uninstall.

Fixes PrestaShop/PrestaShop#34784
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.

ps_emailalerts - Merchant notifications options are all enabled, but with no email saved.

1 participant