Currently, the "Disqus comments" checkbox found on node edit forms is broken, for a couple of reasons. First, in node_update(), there is this code, which has inverted logic. It's closing the thread when the new status is ON:

  // Finish the update process.
  if (isset($node->disqus_status) && isset($node->disqus['status']) && $node->disqus_status != $node->disqus['status']) {
    if ($node->disqus_status) {
      disqus_node_delete($node);
    }
    else {
      disqus_node_insert($node);
    }
  }

The easiest thing is to change this to !$node->disqus_status. That fixes the disqus.com side of things.

But that doesn't solve the problem entirely. The next time the user edits the node, the checkbox will get checked again, even though disqus isn't active for the node. That's because disqus_node_delete() removes the record containing the node's disqus_status. Then, the next node_load() defaults it back to "on":

$node->disqus['status'] = isset($status->status) ? (bool)$status->status : TRUE;

So the better thing is to always create or update the entry in the disqus table for the node. See the attached patch.

CommentFileSizeAuthor
dq.diff761 bytesGribnif
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slashrsm’s picture

The idea behind this logic is to only save items that have Disqus disabled. If there is an item that does not have an entry in mysql table it automatically assumes TRUE.

This way we prevent that table from exploding on sites with huge amounts of content (imagine site with millions of nodes with only 1000s or 10000s of them with disabled commenting).

Gribnif’s picture

@slashrsm: I think you're making an unfair assumption. On our site, for instance, we have 400,000 nodes, only 20-30 of which will ever have Disqus enabled.

Perhaps the default state could be an option, either at the admin/config/services/disqus (global) level or, even better, at the content type level admin/structure/types/manage/[name] in the Comment Settings section.

slashrsm’s picture