Time field does not update when showing a form preview, or returning a form error. Instead, the time field remains the same as the first creation of the form.
Line #223 of honeypot.module should update the field time, but it is not functioning correctly in this situation.
$form_state['values']['honeypot_time'] = time();
I have tried to figure out how to update the value, but I cannot. Please help with this.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | honeypot.preview-fix.2036501-15.patch | 653 bytes | geerlingguy |
| #12 | honeypot.preview-fix.2036501-12.patch | 2.32 KB | geerlingguy |
| #10 | honeypot.preview-fix.2036501-9.patch | 2.33 KB | geerlingguy |
| #7 | honeypot.preview-fix.2036501-7.patch | 5.85 KB | geerlingguy |
| #4 | honeypot.preview-fix.2036501-4.patch | 653 bytes | geerlingguy |
Comments
Comment #1
Sepero commentedI have tried using both of the following without success.
(I think that there is a typo in the validation function definition, and that $form should actually be named as $element. So that is how I am trying to use it in the above code.)
Line #211 of honeypot.module
function _honeypot_time_restriction_validate($form, &$form_state) {Should possibly be written as this?
function _honeypot_time_restriction_validate($element, &$form_state) {Comment #2
Sepero commentedIs the time field properly updating on previews using Drupal 7 or 8?
Comment #3
geerlingguy commentedI'll try taking a look at this. I don't think I've ever tested form previews—this should definitely be added to automated testing!
Comment #4
geerlingguy commentedI've looked into this further, and I think the best solution would be to make it so form submissions that are triggered by the 'Preview' button are not validated via Honeypot. Additionally, the timestamp that Honeypot generates should remain the same as when the form was originally built, because this value is supposed to simply restrict bots that complete the form too quickly from submitting the form; if someone is previewing the form and taking X seconds to do so, that's equivalent in my mind to making sure they take X seconds to simply fill out the form.
Attached patch changes $form to $element (thanks for catching that!), and says 'if someone is previewing the form/node, don't do any timestamp validation.'
Comment #5
geerlingguy commentedI also need to write a test that checks to make sure the timestamp validation doesn't run if a user clicks 'Preview'.
Comment #6
geerlingguy commentedI've tested the above patch in D8, and it works as well. However, I can't do tests until #2111163: Can't Preview comments: Call to a member function id() on a non-object in comment.module, line 1371 has been fixed, because comment form previewing seems to be broken :(
Comment #7
geerlingguy commentedOkay, attaching what I hope will be the final patch for D8 here... I had to fix some other problems caused by failing to stay on top of HEAD for a month or two :)
Comment #8
geerlingguy commentedUpdated title for clarity.
Comment #10
geerlingguy commentedD7 backport of patch from #7 attached. Hopefully this gets a green light; my local D7 testing environment is borked, and D7 testbot should be quicker :)
Comment #12
geerlingguy commentedLet's try this again...
Comment #13
geerlingguy commentedComment #14
geerlingguy commentedReady to be ported to D6 (with no tests, of course!)... here are the commits for:
Comment #15
geerlingguy commentedPatch attached.
Comment #16
geerlingguy commentedAll is well. Thanks to everyone who participated in this issue!
D6 commit: http://drupalcode.org/project/honeypot.git/commit/a774a1d
Comment #18
geerlingguy commentedBad testbot.