mollom_field_extra_fields() does a mollom_form_load() for each node type. On the Drupal 7 site I'm working on that's around half the SQL queries executed on node/n.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, mollom_extra_fields.patch, failed testing.

catch’s picture

Status: Needs work » Needs review

Can't reproduce the test failure locally.

sun’s picture

Title: Cache mollom_field_extra_fields() » mollom_field_extra_fields() only works for nodes, needlessly loads $mollom_forms
FileSize
1.49 KB

wow, what a mess.

Status: Needs review » Needs work

The last submitted patch, mollom-HEAD.field-extra-fields.3.patch, failed testing.

Dries’s picture

If it is such a mess, does it need to be removed altogether? Or what needs to be done so we don't have to guess?

It sounds like a reasonably common use case to me so it is hard to believe Mollom is the only module that has this problem.

sun’s picture

Status: Needs work » Needs review
FileSize
1.94 KB

Hm. Now I see that http://api.drupal.org/api/function/hook_field_extra_fields/7 does not even get those arguments I mistakenly thought it would get...

Problem space being that

1) entity modules registering their _forms_ for possible protection with Mollom

2) user enables/configures any of those registered entity forms

3) Mollom appears on the entity forms as extra field, but only because we integrate with the form_id

4) There is no reverse-relationship from entity -> bundle -> form_id...

On a second thought. Let's try this. Gotta get some dinner now, will come back to this later.

Dries’s picture

I'll postpone testing this given that it has a @todo and per the comment in #6 it might just be a work in progress.

sun’s picture

Resolved that @todo

sun’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.12 KB

um, slightly strange structure expected in that hook. Manually tested attached patch, works.

Speaking of tests, do we want/need to test this? Hm. Let's defer that to #674692: Node module integration tests, so RTBC.

sun’s picture

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

sun’s picture

+++ mollom.module	31 Jul 2010 14:40:28 -0000
@@ -1580,16 +1580,22 @@ function mollom_get_statistics($refresh 
 function mollom_field_extra_fields() {
...
+  foreach (mollom_form_list() as $form_id => $info) {
+    if (isset($info['entity']) && isset($forms[$form_id])) {

blargh. :) #775444: API implementor documentation just made me recall and revisit this patch again.

The code now assumes that every form that registers an 'entity' is a Field API entity.

That's not necessarily the case -- it may be true for all core entities, but technically, contributed and custom modules could register forms to protect by Mollom that are neither using entity API nor field API.

We can keep this issue fixed until someone actually reports a problem about this.

Powered by Dreditor.

Dries’s picture

Umph, but I agree that it is acceptable for now. Might be worthy a code comment ... ?

sun’s picture

Status: Fixed » Needs review
FileSize
1.65 KB
Dries’s picture

Status: Needs review » Fixed

Thanks for the documentation. Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

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

  • Commit 4d508b8 on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #826832 by sun, catch: mollom_field_extra_fields() only works...
  • Commit cf8fc66 on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #826832 by sun, catch: mollom_field_extra_fields() only works...

  • Commit 4d508b8 on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #826832 by sun, catch: mollom_field_extra_fields() only works...
  • Commit cf8fc66 on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #826832 by sun, catch: mollom_field_extra_fields() only works...