When mailhandler fetches more than one mail, and validate them, if a mail reports a validation error the same error will be "duplicated" to all messages after that.
The problem in in mailhandler_node_submit function, where it does:
node_validate($node);
$error = form_get_errors();
It does the 2 lines above for each mail, but nowhere there is a reset of form_errors, so after a validation for a message reports an error (via form_set_error), that error message will remain for all remaining mails.
The GREAT problem is that i can see no way to reset form_errors...
The only way seems to patch form.inc function "form_set_error" to implements a reset of the static $form variable.
What do you think?
Comment | File | Size | Author |
---|---|---|---|
#16 | mailhandler-validation-271975-16.patch | 2.47 KB | Ian Ward |
#8 | mailhandler-1.patch | 810 bytes | gotheric |
#6 | mailhandler.patch | 2.15 KB | gotheric |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedPerhaps we need to submit the node using drupal_execute()? Would that still do all our validation? Would it reset errors? Ugh.
Comment #2
gotheric CreditAttribution: gotheric commentedNo, i don't think that will solve the problem.
The core doesn't support multiple validations, and i don't think of a "clean" way to do that.
(Or maybe i'm missing something...)
However i submitted a core support request:
#272042: There is no way to reset validation errors
Comment #3
gotheric CreditAttribution: gotheric commentedAssuming the problem won't be fixed on 5.x (and i think 6.x too) i see only one way to fix the problem without patching the core.
It's not a "smart" way but it should work.
We must work with error messages set by "drupal_set_message" (form_set_error calls it for each validation error, and drupal_set_message data is contained on $_SESSION['messages'], which is visibile outside the function).
This should be something like that (this is just a quick example, if you think it should be a good way i'll do the patch):
Only an example that should be tuned (i should also catch errors on "..." code...).
Could that be a solution (hoping and waiting for a real fix on 7.x)?
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedYes, that looks like a clever solution. I'd welcome such a patch. Please add a comment so we know why we have to do this madness.
For 7.x, please help on a related patch in. See #254491: Standardize static caching
Comment #5
gotheric CreditAttribution: gotheric commentedSounds interesting, i'll look at it.
I'll check & submit mailhandler patch next week (monday or tuesday).
Comment #6
gotheric CreditAttribution: gotheric commentedHere is the patch.
(I think it should be applied easily to 6.x branch too).
Comment #7
moshe weitzman CreditAttribution: moshe weitzman commentedI've committed this to 5.x and 6.x. I'd love some feedback in the next few days. If I hear no negative feedback, I will make new releases. I am not setup for testing this now, so I've committed blindly. Please give feedback, folks.
Comment #8
gotheric CreditAttribution: gotheric commentedJust a little mod, to avoid having the $_SESSION['messages']['error'] with an empty array (standard theme will display an empty error box).
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedCommitted. Please use braces even on 1 line if() statement. Just part of our coding standards.
I am going to make a new release of mailhandler since I can't seem to get any feedback otherwise.
Comment #10
catchI've just been setting mailhandler up for the first time, had it checking the inbox but no content was being created. Since I was adding more and more unread variations of the same message with different versions of the commands, I'd obviously ended up triggering this bug, new release of mailhandler fixed it and has probably saved me hours and hours of head scratching. Thanks!
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commented#180063: No way to flush form errors during iterative programatic form submission has been committed to D6. we can undo the mess in mailhandler_node_submit() now.
Comment #13
z.stolar CreditAttribution: z.stolar commented@Moshe: How? Is it by calling form_set_error with ($reset = TRUE) after node_validate?
Can you show me the way? (I'll walk it :-) )
Comment #14
moshe weitzman CreditAttribution: moshe weitzman commentedYes, thats the idea
Email me when you have a need because I am rarely reading mailhandler issue mail these days.
Comment #15
Ian Ward CreditAttribution: Ian Ward commentedIt looks like this can all boil down to:
I am working on a 6.2 version which will hopefully be ready enough to commit back to CVS and I've tested the above in it which works. I tested by sending three emails, the first two with validation errors and the last without, and the last one passed validation fine while the first two were correctly found invalid. I'll likely commit this after another point release in 6.1.
Comment #16
Ian Ward CreditAttribution: Ian Ward commentedAttached is the patch per #15
Comment #17
Ian Ward CreditAttribution: Ian Ward commentedApplied to 6.1. Should be ported to 7.1
Comment #18
cor3huis CreditAttribution: cor3huis commentedSet to HEAD so the port is not forgotten, also since work on a 7.1 is unlikely as I understood from other issues
Comment #19
cor3huis CreditAttribution: cor3huis commentedBump, unclear if patch is integrated. If so plz close this issue, if not it would be lovely to have it integrated in main.
Comment #20
Dane Powell CreditAttribution: Dane Powell commentedComment #21
Dane Powell CreditAttribution: Dane Powell commentedYes, this has been committed to 7.x-1.x.