summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/comment.module6
-rw-r--r--modules/comment/comment.test22
2 files changed, 25 insertions, 3 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index ecb73af92..56000102c 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -589,8 +589,10 @@ function comment_form_alter(&$form, $form_state, $form_id) {
function comment_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
case 'load':
- return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid));
- break;
+ if ($node->comment != COMMENT_NODE_DISABLED) {
+ return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid));
+ }
+ return array('last_comment_timestamp' => $node->created, 'last_comment_name' => '', 'commenet_count' => 0);
case 'prepare':
if (!isset($node->comment)) {
diff --git a/modules/comment/comment.test b/modules/comment/comment.test
index 095f04548..c1630d6dd 100644
--- a/modules/comment/comment.test
+++ b/modules/comment/comment.test
@@ -69,10 +69,20 @@ class CommentTestCase extends DrupalWebTestCase {
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName());
$this->assertTrue($this->commentExists($reply, TRUE), t('Modified reply found.'));
+ // Pager
+ $this->setCommentsPerPage(2);
+ $comment_new_page = $this->postComment($this->node, $this->randomName(), $this->randomName());
+ $this->drupalGet('node/' . $this->node->nid);
+ $this->assertTrue($this->commentExists($comment) && $this->commentExists($comment_new_page), t('Page one exists. %s'));
+ $this->drupalGet('node/' . $this->node->nid, array('query' => 'page=1'));
+ $this->assertTrue($this->commentExists($reply, TRUE), t('Page two exists. %s'));
+ $this->setCommentsPerPage(50);
+
// Delete comment and make sure that reply is also removed.
$this->drupalLogout();
$this->drupalLogin($this->admin_user);
$this->deleteComment($comment);
+ $this->deleteComment($comment_new_page);
$this->drupalGet('node/' . $this->node->nid);
$this->assertFalse($this->commentExists($comment), t('Comment not found.'));
@@ -294,7 +304,7 @@ class CommentTestCase extends DrupalWebTestCase {
$regex .= $comment->comment . '(.*?)'; // Match comment.
$regex .= '<\/div>/s'; // Dot matches newlines and ensure that match doesn't bleed outside comment div.
- return preg_match($regex, $this->drupalGetContent());
+ return (boolean)preg_match($regex, $this->drupalGetContent());
}
else {
return FALSE;
@@ -353,6 +363,16 @@ class CommentTestCase extends DrupalWebTestCase {
}
/**
+ * Set the default number of comments per page.
+ *
+ * @param integer $comments
+ * Comments per page value.
+ */
+ function setCommentsPerPage($number) {
+ $this->setCommentSettings('comment_default_per_page', $number, 'Number of comments per page set to ' . $number .'.');
+ }
+
+ /**
* Set comment setting for article content type.
*
* @param string $name