SELECT * FROM mollom_form WHERE form_id = 'note_node_form' LIMIT 0, 1
This query gets called for every node on node listing pages. The forms aren't even being displayed, so there's nothing to protect, and in any case, some static caching could be used to prevent the redundant queries.

CommentFileSizeAuthor
#3 774816-mollom-cache-get-mode-D6.patch974 bytesdave reid

Comments

dave reid’s picture

Assigned: Unassigned » dave reid
dave reid’s picture

The query comes from the code to add the 'report to Mollom' links in mollom_link(). We should add some caching to either mollom_get_mode() or mollom_load_form() so that this does not need to be loaded on every, single call to mollom_get_mode().

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new974 bytes

Patch to statically cache mollom_get_mode(). Helped reduce the number of queries just to the number of unique node types on a node display.

Does not apply to D7 since we do not have mollom_get_mode() or use links in that verison.

sun’s picture

Basically, this static caching rather belongs into mollom_form_load(). But for now, I'd move forward with this patch here, because entire loading/caching will need to get changed via #717874: Provide exportables for Mollom forms

dries’s picture

Does that mean we should add a todo?

sun’s picture

I don't think so... the exportables issue is enough of a todo. Not sure about CTools/Features' status for D7, but ideally, exportables support should only be added there.

dave reid’s picture

Anyone want to mark as RTBC then? :)

sun’s picture

Status: Needs review » Reviewed & tested by the community
dries’s picture

+++ mollom.module	18 Apr 2010 21:51:52 -0000
@@ -678,8 +678,14 @@ function mollom_delete_form_list($reset 
+  if (!isset($modes[$form_id])) {
+    $mollom_form = mollom_form_load($form_id);
+    $modes[$form_id] = isset($mollom_form['mode']) ? $mollom_form['mode'] : MOLLOM_MODE_DISABLED;
+  }
  1. Minor: mollom_form_load() is documented to be a menu loader but it is obviously used in different contexts too.
  2. Minor: wouldn't it be nicer if $mollom_form['mode] defaulted to MOLLOM_MODE_DISABLED so we can avoid the isset()? We already prepare a default $mollom_form in mollom_form_load(), it seems. See the following snippet taken from mollom_form_load():
        // Ensure default values (partially for administrative configuration).
        $mollom_form += array(
          'form_id' => $form_id,
          'title' => $form_id,
          'elements' => array(),
        );
    

    I haven't tested it but it seems like we might be able to add a 'mode' => MOLLOM_MODE_DISABLED.

dave reid’s picture

I think the problem with adding a default in mollom_form_load() is that function could return FALSE if the form_id is not provided by any hook_mollom_form_info(). Therefore we would still have to check if $mollom_form is FALSE in mollom_get_mode().\

Plus, that default value is actually loaded in mollom_form_info().

dave reid’s picture

Status: Reviewed & tested by the community » Fixed

Committed #3 to DRUPAL-6--1.
http://drupal.org/cvs?commit=363636

dries’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Fixed » Patch (to be ported)

Actually, this needs to be ported to CVS HEAD (Drupal 7) before it can be marked 'fixed'. Let's try to keep CVS HEAD in sync.

dave reid’s picture

Status: Patch (to be ported) » Fixed

The mollom_get_mode() function isn't in the D7 branch since we don't add the 'Report to Mollom' links. :)

Status: Fixed » Closed (fixed)

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