Commit 12ead318 authored by Dries's avatar Dries
Browse files

- Patch #613278 by Dave Reid, mfb: fixed forum module and added tests.

parent e88a2178
......@@ -463,7 +463,7 @@ function forum_field_storage_pre_update($obj_type, $object, &$skip_fields) {
foreach ($language as $delta) {
$query->values(array(
'nid' => $object->nid,
'title' => $object->title,
'title' => $object->title[FIELD_LANGUAGE_NONE][0]['value'],
'tid' => $delta['value'],
'sticky' => $object->sticky,
'created' => $object->created,
......@@ -1107,14 +1107,14 @@ function _forum_update_forum_index($nid) {
if ($count > 0) {
// Comments exist.
$last_reply = db_query_range('SELECT cid, name, timestamp, uid FROM {comment} WHERE nid = :nid AND status = :status ORDER BY cid DESC', array(
$last_reply = db_query_range('SELECT cid, name, created, uid FROM {comment} WHERE nid = :nid AND status = :status ORDER BY cid DESC', 0, 1, array(
':nid' => $nid,
':status' => COMMENT_PUBLISHED,
), 0, 1)->fetchObject();
))->fetchObject();
db_update('forum_index')
->fields( array(
'comment_count' => $count,
'last_comment_timestamp' => $last_reply->timestamp,
'last_comment_timestamp' => $last_reply->created,
))
->condition('nid', $nid)
->execute();
......
......@@ -75,6 +75,16 @@ class ForumTestCase extends DrupalWebTestCase {
$this->createForumTopic($this->forum, FALSE);
$this->createForumTopic($this->forum, FALSE);
$this->drupalGet('node');
// Test adding a comment to a forum topic.
$node = $this->createForumTopic($this->forum, FALSE);
$this->drupalPost("node/$node->nid", array('comment' => $this->randomName()), t('Save'));
$this->assertResponse(200);
// Test editing a forum topic that has a comment.
$this->drupalLogin($this->any_user);
$this->drupalPost("node/$node->nid/edit", array(), t('Save'));
$this->assertResponse(200);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment