- Patch #250729 by R.Muilwijk: removed unnecessary SQL query.
parent
a1537c3e28
commit
cf42d0c25a
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
|
@ -352,6 +362,16 @@ class CommentTestCase extends DrupalWebTestCase {
|
|||
$this->setCommentSettings('comment_anonymous', $level, 'Anonymous commenting set to level ' . $level . '.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue