Tell the customer when a duplicate message was not sent - #103
Draft
boo-code wants to merge 1 commit into
Draft
Conversation
sendMessage() skips storing a message that repeats the last one already on the customer thread, and sets mailAlreadySend so no notification goes out. The success branch did not look at that flag, so the customer was told the message had been sent to the team while nothing was stored and the merchant received nothing. The thread is found by the sender's email address, so this is reached by anyone writing in twice with the same text, and by a logged-in customer whose email is prefilled for them. It looks exactly like the form failing in silence. The de-duplication itself is left alone; only the message shown now reflects what happened.
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.
sendMessage()drops a message whose text is identical to the last one on the same thread and sets$mailAlreadySend, which also skips the notification e-mail. The success branch below never looks at that flag, so the customer is told "Your message has been successfully sent to our team." while nothing was stored and nobody was notified. The thread is looked up by e-mail address, so a logged-in customer always lands on their existing thread and hits this every time they resend the same text, while a guest with a fresh address never does. The success message is now only shown when something was actually sent, and a duplicate reports that it was already received.What the issue says vs what is actually broken
The report blames "Server Cache ON". That is not it. Measured on 9.2 with contactform 4.4.3, submitting
the real form over HTTP:
PS_SMARTY_CACHE=1,PS_SMARTY_FORCE_COMPILE=1(dev)PS_SMARTY_CACHE=1,PS_SMARTY_FORCE_COMPILE=0(production, never recompile)The widget is never Smarty-cached either way:
renderWidget()callsdisplay()with no$cache_id, soTools::enableCache()is not reached, andHook::coreRenderWidget()has no cache of its own. Two visitorsalso get two different form tokens, so nothing is being shared.
The real defect is a silent duplicate drop that reports success.
sendMessage():The success branch never looks at
$mailAlreadySend. Measured, three submissions from one email address:Nothing is stored, no notification reaches the merchant, and the customer is told it arrived.
The thread is looked up by email address
(
CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, $id_order)), which is why @pollat sees it forlogged-in customers: their address is prefilled, so they always land on their existing thread, while a guest
typing a fresh address gets a new thread and always succeeds. That is their "if logged user use prestashop
contact form, no mail are recived by admin ... if not logged user send mail by contact form, the mail arrive".
The fix
Report what actually happened. The de-duplication is left as it is.
After:
Mutation check: with the unpatched module back in place (verified by grep), both sends report
"successfully sent" while only one is stored.
Adds one new translation string in
Modules.Contactform.Shop.Deliberately left for a maintainer decision
The de-duplication compares only against the last message on a thread, and the thread never expires. So a
customer who writes the same sentence months apart is still silently de-duplicated, and the merchant is never
told. Whether that rule should have a time window, or should notify anyway, is the specification this issue is
labelled as needing. Raised in the issue comment; not changed here.
Conflict check
Only open PR touching
contactform.phpis #100 (Hlavtox, "Release version 4.4.4", basemaster), whosehunk is at
@@ -530- theuser_agentlength change, already present ondev. This change is at ~line 668 ondev. No overlap, and different base branches.Verification
php -lclean