The placeholder field count is inconsistent with the array of fields provided in function views_handler_field_node_new_comments::pre_render. The placeholder :timestamp, is repeated in the query causing an error in advanced forums using Microsoft SQL server.

According to the database abstraction layer https://api.drupal.org/api/drupal/includes!database!database.inc/group/d... a given placeholder label cannot be repeated in a given query, even if the value should be the same.

The error I am getting is similar to several others like https://www.drupal.org/node/1576714 and https://www.drupal.org/node/1598924

In order to fix this error, the query:

$result = db_query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comment} c ON n.nid = c.nid
LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = :h_uid WHERE n.nid IN (:nids)
AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp), :timestamp) AND c.status = :status GROUP BY n.nid ", array(
':status' => COMMENT_PUBLISHED,
':h_uid' => $user->uid,
':nids' => $nids,
':timestamp' => NODE_NEW_LIMIT,
));

should read:

$result = db_query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comment} c ON n.nid = c.nid
LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = :h_uid WHERE n.nid IN (:nids)
AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp1), :timestamp2) AND c.status = :status GROUP BY n.nid ", array(
':status' => COMMENT_PUBLISHED,
':h_uid' => $user->uid,
':nids' => $nids,
':timestamp1' => NODE_NEW_LIMIT,
':timestamp2' => NODE_NEW_LIMIT,
));

Thank you,
jpoika

Comments

jpoika’s picture

Status: Active » Needs review

I tested this with the dev version as well. It is still a problem that this patch will fix.

Chris Matthews’s picture

@jpoika, if this is still a distinct issue that exists on the latest views 7.x-3.x-dev can you attach a patch file for reviewing & testing?