With the commit of #1034334: Refactor reply form out of privatemsg_new() validate and submit handlers were bound specifically to the submit button and this prevents execution of other handlers bound globally to the form. Mollom validators are affected by this.

CommentFileSizeAuthor
#3 1178796_complete.patch3.46 KBberdir
#2 1178796.patch2.29 KBberdir

Comments

sun’s picture

Button-level submit handlers are a pain.

See #674692: Node module integration tests for a directly related Mollom issue.
See #1150756: Improve integration with entity form button-level and form-level submit handlers, form/entity (re-)building, and previews for a corresponding D8 core issue.

berdir’s picture

Status: Active » Needs review
StatusFileSize
new2.29 KB

Better? :)

berdir’s picture

StatusFileSize
new3.46 KB

Forgot privatemsg_forward.module...

ufku’s picture

Status: Needs review » Reviewed & tested by the community

Mollom is ok with the patch.

sun’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/privatemsg.pages.inc
@@ -393,7 +393,6 @@ function _privatemsg_form_base_fields(&$form_state) {
     $form['preview'] = array(
       '#type'     => 'submit',
       '#value'    => t('Preview message'),
-      '#validate' => array('privatemsg_new_validate'),
       '#submit'   => array('privatemsg_new_preview'),
       '#weight'   => 10,
     );

@@ -403,10 +402,11 @@ function _privatemsg_form_base_fields(&$form_state) {
+  $form['#validate'] = array('privatemsg_new_validate');
+  $form['#submit'] = array('privatemsg_new_submit');
+
   return $form;

This likely means that Mollom won't be invoked for previews, right?

As mentioned above, the situation for how to handle button-level and form-level submit handlers throughout Drupal isn't entirely clear. But since this pattern exists at least in Node module and Mollom thus needs to support it anyway, an alternative would be to enhance Mollom's module integration API to allow modules to define the form key to attach its form handlers to.

That, however, would still require privatemsg to fully follow Node module's weird construct; i.e., the button-level submit handler invokes all form-level submit handlers. By default, without that special construct, button-level #submit handlers will not execute form-level #submit handlers.

Powered by Dreditor.

berdir’s picture

Yes, it won't work for the preview. Not sure how much of a problem that is, though.

Because what isn't visible in that patch is that Preview button is now optional and in fact disabled by default. And even if enabled, the form is still protected, the only problem is that you will get an eventual confirmation CAPTCHA only when actually submitting the form and not previewing it.

sun’s picture

If this patch works for you, then I guess it's ok.

Mollom is still invoked for previews, because it mainly acts as a form validation handler.

Mollom's form submit handling logic only stores the final result; i.e., to be able to report a post to Mollom later on.

Thus, as long as Mollom is invoked after the primary #submit handler of privatemsg for the (non-preview) 'submit' action, then everything should be fine.

berdir’s picture

Status: Needs review » Fixed

Ok. Yes, after a preview, you still need to submit it again, just like you would when you haven't previewed.

Commited this patch to 6.x-2.x.

In 7.x-2.x, we already did it like that to prevent a possible bug, triggered by some dev versions of organic groups.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.