summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/comment/comment.admin.inc19
-rw-r--r--modules/comment/comment.install117
-rw-r--r--modules/comment/comment.module112
-rw-r--r--modules/comment/comment.pages.inc1
-rw-r--r--modules/comment/comment.test23
-rw-r--r--modules/comment/comment.tpl.php2
-rw-r--r--modules/forum/forum.test4
-rw-r--r--modules/search/search.test26
-rw-r--r--modules/tracker/tracker.test8
-rw-r--r--modules/trigger/trigger.test2
-rw-r--r--modules/user/user.test9
11 files changed, 234 insertions, 89 deletions
diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc
index 9c773dec5..5fed67a35 100644
--- a/modules/comment/comment.admin.inc
+++ b/modules/comment/comment.admin.inc
@@ -67,31 +67,38 @@ function comment_admin_overview($form, &$form_state, $arg) {
);
$query = db_select('comment', 'c')->extend('PagerDefault')->extend('TableSort');
- $query->join('users', 'u', 'u.uid = c.uid');
$query->join('node', 'n', 'n.nid = c.nid');
- $query->addField('u', 'name', 'registered_name');
$query->addField('n', 'title', 'node_title');
$result = $query
- ->fields('c', array('subject', 'nid', 'cid', 'comment', 'changed', 'status', 'name', 'homepage'))
- ->fields('u', array('uid'))
+ ->fields('c', array('cid', 'subject', 'name', 'changed'))
->condition('c.status', $status)
->limit(50)
->orderByHeader($header)
->execute();
+ // We collect a sorted list of node_titles during the query to attach to the
+ // comments later.
+ foreach ($result as $row) {
+ $cids[] = $row->cid;
+ $node_titles[] = $row->node_title;
+ }
+ $comments = comment_load_multiple($cids);
// Build a table listing the appropriate comments.
$options = array();
$destination = drupal_get_destination();
- foreach ($result as $comment) {
+ foreach ($comments as $comment) {
+ // Dequeue the first node title from the node_titles array and attach to
+ // the comment.
+ $comment->node_title = array_shift($node_titles);
$options[$comment->cid] = array(
'subject' => array(
'data' => array(
'#type' => 'link',
'#title' => $comment->subject,
'#href' => 'comment/' . $comment->cid,
- '#options' => array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'fragment' => 'comment-' . $comment->cid),
+ '#options' => array('attributes' => array('title' => truncate_utf8($comment->comment_body[LANGUAGE_NONE][0]['value'], 128)), 'fragment' => 'comment-' . $comment->cid),
),
),
'author' => theme('username', array('account' => $comment)),
diff --git a/modules/comment/comment.install b/modules/comment/comment.install
index 9a571c159..b2106da20 100644
--- a/modules/comment/comment.install
+++ b/modules/comment/comment.install
@@ -10,6 +10,9 @@
* Implements hook_uninstall().
*/
function comment_uninstall() {
+ // Delete comment_body field.
+ field_delete_field('comment_body');
+
// Remove variables.
variable_del('comment_block_count');
$node_types = array_keys(node_type_get_types());
@@ -43,6 +46,32 @@ function comment_enable() {
db_insert('node_comment_statistics')
->from($query)
->execute();
+
+ // Create comment body field.
+ // @todo this should be done in comment_install, but causes exceptions
+ // in testing because the list of fields types is not available in
+ // hook_install(): _field_info_collate_types() returns an empty array.
+ if (!field_info_field('comment_body')) {
+ $field = array(
+ 'field_name' => 'comment_body',
+ 'type' => 'text_long',
+ );
+ field_create_field($field);
+ }
+
+ // There is a separate comment bundle for each node type to allow for
+ // per-node-type customization of comment fields. Each one of these bundles
+ // needs a comment body field instance. A comment bundle is needed even for
+ // node types whose comments are disabled by default, because individual nodes
+ // may override that default.
+ // @todo This should be changed to call field_attach_create_bundle() instead,
+ // and a comment_field_attach_create_bundle() function should be added to
+ // handle the creation of the comment body field instance.
+ foreach (node_type_get_types() as $type => $info) {
+ if (!field_info_instance('comment', 'comment_body', 'comment_node_' . $info->type)) {
+ _comment_body_field_instance_create($info);
+ }
+ }
}
/**
@@ -215,6 +244,81 @@ function comment_update_7011() {
}
/**
+ * Create the comment_body field.
+ */
+function comment_update_7012() {
+ // Create comment body field.
+ $field = array(
+ 'field_name' => 'comment_body',
+ 'type' => 'text_long',
+ );
+ field_create_field($field);
+
+ // Add the field to comments for all existing bundles.
+ $body_instance = array(
+ 'field_name' => 'comment_body',
+ 'label' => 'Comment',
+ 'object_type' => 'comment',
+ 'settings' => array('text_processing' => 1),
+ // Hide field label by default.
+ 'display' => array(
+ 'full' => array(
+ 'label' => 'hidden',
+ ),
+ ),
+ );
+ foreach (node_type_get_types() as $info) {
+ $body_instance['bundle'] = 'comment_node_' . $info->type;
+ field_create_instance($body_instance);
+ }
+}
+
+/**
+ * Migrate data from the comment field to field storage.
+ */
+function comment_update_7013(&$sandbox) {
+ // This is a multipass update. First set up some comment variables.
+ if (empty($sandbox['total'])) {
+ $comments = (bool) db_query_range('SELECT 1 FROM {comment}', 0, 1)->fetchField();
+ $sandbox['types'] = array();
+ if ($comments) {
+ $sandbox['etid'] = _field_sql_storage_etid('comment');
+ $sandbox['types'] = node_type_get_types();
+ }
+ $sandbox['total'] = count($sandbox['types']);
+ }
+ if (!empty($sandbox['types'])) {
+ $type = array_shift($sandbox['types']);
+
+ $query = db_select('comment', 'c');
+ $query->innerJoin('node', 'n', 'c.nid = n.nid AND n.type = :type', array(':type' => $type->type));
+ $query->addField('c', 'cid', 'entity_id');
+ $query->addExpression("'comment_node_$type->type'", 'bundle');
+ $query->addExpression($sandbox['etid'], 'etid');
+ $query->addExpression('0', 'deleted');
+ $query->addExpression("'" . LANGUAGE_NONE . "'", 'language');
+ $query->addExpression('0', 'delta');
+ $query->addField('c', 'comment', 'comment_body_value');
+ $query->addField('c', 'format', 'comment_body_format');
+
+ $comment_body = field_info_field('comment_body');
+ $comment_body_table = _field_sql_storage_tablename($comment_body);
+
+ db_insert($comment_body_table)
+ ->from($query)
+ ->execute();
+ }
+
+ // On the last pass of the update, $sandbox['types'] will be empty.
+ if (empty($sandbox['types'])) {
+ db_drop_field('comment', 'comment');
+ db_drop_field('comment', 'format');
+ }
+
+ $sandbox['#finished'] = 1 - count($sandbox['types']) / $sandbox['total'];
+}
+
+/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
@@ -256,12 +360,6 @@ function comment_schema() {
'default' => '',
'description' => 'The comment title.',
),
- 'comment' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'The comment body.',
- ),
'hostname' => array(
'type' => 'varchar',
'length' => 128,
@@ -289,13 +387,6 @@ function comment_schema() {
'size' => 'tiny',
'description' => 'The published status of a comment. (0 = Not Published, 1 = Published)',
),
- 'format' => array(
- 'type' => 'int',
- 'size' => 'small',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'The {filter_format}.format of the comment body.',
- ),
'thread' => array(
'type' => 'varchar',
'length' => 255,
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index a0ead3b8d..d320aa005 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -245,6 +245,9 @@ function comment_count_unpublished() {
*/
function comment_node_type_insert($info) {
field_attach_create_bundle('comment', 'comment_node_' . $info->type);
+ // @todo Create a comment_field_attach_create_bundle() function, and have that
+ // function create the comment body field instance.
+ _comment_body_field_instance_create($info);
}
/**
@@ -275,6 +278,28 @@ function comment_node_type_delete($info) {
}
}
+ /**
+ * Helper function which creates a comment body field instance for a given node
+ * type.
+ */
+function _comment_body_field_instance_create($info) {
+ // Attaches the body field by default.
+ $instance = array(
+ 'field_name' => 'comment_body',
+ 'label' => 'Comment',
+ 'object_type' => 'comment',
+ 'bundle' => 'comment_node_' . $info->type,
+ 'settings' => array('text_processing' => 1),
+ // Hides field label by default.
+ 'display' => array(
+ 'full' => array(
+ 'label' => 'hidden',
+ ),
+ ),
+ );
+ field_create_instance($instance);
+}
+
/**
* Implements hook_permission().
*/
@@ -852,15 +877,37 @@ function comment_build_content($comment, $node, $view_mode = 'full') {
// Remove previously built content, if exists.
$comment->content = array();
- // Build comment body.
- $comment->content['comment_body'] = array(
- '#markup' => check_markup($comment->comment, $comment->format, '', TRUE),
- );
-
// Build fields content.
field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode);
$comment->content += field_attach_view('comment', $comment, $view_mode);
+ // Prior to Drupal 7, the comment body was a simple text variable, but with
+ // Drupal 7, it has been upgraded to a field. However, using theme('field') to
+ // render the comment body results in a noticeable performance degradation for
+ // pages with many comments. By unsetting #theme, we avoid the overhead of
+ // theme('field') and instead settle for simply rendering the formatted field
+ // value that exists as a child element of the 'comment_body' render array,
+ // which results in equivalent markup and rendering speed as if the comment
+ // body had not been upgraded to a field. Modules that require the comment
+ // body to be rendered as a full field (and are willing to accept the
+ // corresponding performance impact) can restore #theme to 'field' within a
+ // hook_comment_view() or hook_comment_view_alter() implementation.
+ // @todo Bypassing theme('field') is not ideal, because:
+ // - The field label is not displayed, even if its setting is to be
+ // displayed.
+ // - hook_preprocess_field() functions do not run, and therefore, attributes
+ // added in those functions (for example, for RDF) are not output.
+ // - The HTML markup that's within field.tpl.php is not output, so theme
+ // developers must use different CSS rules for the comment body than for
+ // all other fields.
+ // The goal is for theme('field') to be sufficiently optimized prior to
+ // Drupal 7 release, so that this code can be removed, and the comment body
+ // can be rendered just like all other fields. Otherwise, another solution
+ // to the above problems will be needed. @see http://drupal.org/node/659788.
+ if (isset($comment->content['comment_body']['#theme']) && ($comment->content['comment_body']['#theme'] === 'field')) {
+ unset($comment->content['comment_body']['#theme']);
+ }
+
if (empty($comment->in_preview)) {
$comment->content['links']['comment'] = array(
'#theme' => 'links',
@@ -1173,17 +1220,14 @@ function comment_node_delete($node) {
* Implements hook_node_update_index().
*/
function comment_node_update_index($node) {
- $text = '';
- if ($node->comment != COMMENT_NODE_HIDDEN) {
- $comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(
- ':nid' => $node->nid,
- ':status' => COMMENT_PUBLISHED
- ));
- foreach ($comments as $comment) {
- $text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, '', TRUE);
- }
+ $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED);
+ $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
+ if ($node->comment && $cids = comment_get_thread($node, $mode, $comments_per_page)) {
+ $comments = comment_load_multiple($cids);
+ comment_prepare_thread($comments);
+ $build = comment_view_multiple($comments, $node);
}
- return $text;
+ return drupal_render($build);
}
/**
@@ -1304,8 +1348,6 @@ function comment_save($comment) {
'created' => $comment->created,
'changed' => $comment->changed,
'subject' => $comment->subject,
- 'comment' => $comment->comment,
- 'format' => $comment->comment_format,
'uid' => $comment->uid,
'name' => $comment->name,
'mail' => $comment->mail,
@@ -1380,8 +1422,6 @@ function comment_save($comment) {
'pid' => empty($comment->pid) ? 0 : $comment->pid,
'uid' => $comment->uid,
'subject' => $comment->subject,
- 'comment' => $comment->comment,
- 'format' => $comment->comment_format,
'hostname' => ip_address(),
'created' => $comment->created,
'changed' => $comment->changed,
@@ -1700,6 +1740,11 @@ function comment_form($form, &$form_state, $comment) {
);
}
+ // Sets the author form elements above the subject.
+ $form['author'] = array(
+ '#weight' => -2,
+ );
+
// Prepare default values for form elements.
if ($is_admin) {
$author = ($comment->uid && $comment->name ? $comment->name : $comment->registered_name);
@@ -1802,14 +1847,7 @@ function comment_form($form, &$form_state, $comment) {
'#maxlength' => 64,
'#default_value' => $comment->subject,
'#access' => variable_get('comment_subject_field_' . $node->type, 1) == 1,
- );
- $form['comment'] = array(
- '#type' => 'textarea',
- '#title' => t('Comment'),
- '#default_value' => $comment->comment,
- '#text_format' => isset($comment->format) ? $comment->format : filter_default_format(),
- '#required' => TRUE,
- '#rows' => 15,
+ '#weight' => -1,
);
// Used for conditional validation of author fields.
@@ -1870,8 +1908,7 @@ function comment_preview($comment) {
$node = node_load($comment->nid);
if (!form_get_errors()) {
- $comment->format = $comment->comment_format;
-
+ $comment->format = $comment->comment_body[LANGUAGE_NONE][0]['format'];
// Attach the user and time information.
if (!empty($comment->name)) {
$account = user_load_by_name($comment->name);
@@ -1998,7 +2035,8 @@ function comment_submit($comment) {
// 1) Filter it into HTML
// 2) Strip out all HTML tags
// 3) Convert entities back to plain-text.
- $comment['subject'] = truncate_utf8(trim(decode_entities(strip_tags(check_markup($comment['comment'], $comment['comment_format'])))), 29, TRUE);
+
+ $comment['subject'] = truncate_utf8(trim(decode_entities(strip_tags(check_markup($comment['comment_body'][LANGUAGE_NONE][0]['value'], $comment['comment_body'][LANGUAGE_NONE][0]['format'])))), 29, TRUE);
// Edge cases where the comment body is populated only by HTML tags will
// require a default subject.
if ($comment['subject'] == '') {
@@ -2081,6 +2119,7 @@ function template_preprocess_comment(&$variables) {
$variables['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : '';
$variables['signature'] = $comment->signature;
$variables['title'] = l($comment->subject, 'comment/' . $comment->cid, array('fragment' => "comment-$comment->cid"));
+ $variables['permalink'] = l('#', 'comment/' . $comment->cid, array('fragment' => "comment-$comment->cid"));
$variables['template_files'][] = 'comment-' . $variables['node']->type;
// Helpful $content variable for templates.
@@ -2375,7 +2414,8 @@ function comment_unpublish_action($comment, $context = array()) {
*/
function comment_unpublish_by_keyword_action($comment, $context) {
foreach ($context['keywords'] as $keyword) {
- if (strpos($comment->comment, $keyword) !== FALSE || strpos($comment->subject, $keyword) !== FALSE) {
+ $text = drupal_render($comment);
+ if (strpos($text, $keyword) !== FALSE) {
$comment->status = COMMENT_NOT_PUBLISHED;
watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));
break;
@@ -2447,16 +2487,6 @@ function comment_menu_alter(&$items) {
}
/**
- * Implements hook_filter_format_delete().
- */
-function comment_filter_format_delete($format, $fallback) {
- db_update('comment')
- ->fields(array('format' => $fallback->format))
- ->condition('format', $format->format)
- ->execute();
-}
-
-/**
* Implements hook_rdf_mapping().
*/
function comment_rdf_mapping() {
diff --git a/modules/comment/comment.pages.inc b/modules/comment/comment.pages.inc
index 345b9ceb7..9435b8393 100644
--- a/modules/comment/comment.pages.inc
+++ b/modules/comment/comment.pages.inc
@@ -108,7 +108,6 @@ function comment_reply($node, $pid = NULL) {
*/
function comment_approve($comment) {
$comment->status = COMMENT_PUBLISHED;
- $comment->comment_format = $comment->format;
comment_save($comment);
drupal_set_message(t('Comment approved.'));
diff --git a/modules/comment/comment.test b/modules/comment/comment.test
index 117ba7b99..7e6495c6e 100644
--- a/modules/comment/comment.test
+++ b/modules/comment/comment.test
@@ -28,8 +28,9 @@ class CommentHelperCase extends DrupalWebTestCase {
* array of values to set contact info.
*/
function postComment($node, $comment, $subject = '', $contact = NULL) {
+ $langcode = LANGUAGE_NONE;
$edit = array();
- $edit['comment'] = $comment;
+ $edit['comment_body[' . $langcode . '][0][value]'] = $comment;
$preview_mode = variable_get('comment_preview_article', DRUPAL_OPTIONAL);
$subject_mode = variable_get('comment_subject_field_article', 1);
@@ -261,6 +262,7 @@ class CommentInterfaceTest extends CommentHelperCase {
* Test comment interface.
*/
function testCommentInterface() {
+ $langcode = LANGUAGE_NONE;
// Set comments to have subject and preview disabled.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_DISABLED);
@@ -360,7 +362,7 @@ class CommentInterfaceTest extends CommentHelperCase {
$this->assertTrue($this->node, t('Article node created.'));
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertNoText('This discussion is closed', t('Posting to node with comments enabled'));
- $this->assertField('edit-comment', t('Comment body field found.'));
+ $this->assertField('edit-comment-body-' . $langcode . '-0-value', t('Comment body field found.'));
// Delete comment and make sure that reply is also removed.
$this->drupalLogout();
@@ -406,6 +408,8 @@ class CommentPreviewTest extends CommentHelperCase {
* Test comment preview.
*/
function testCommentPreview() {
+ $langcode = LANGUAGE_NONE;
+
// As admin user, configure comment settings.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(TRUE);
@@ -418,23 +422,24 @@ class CommentPreviewTest extends CommentHelperCase {
$this->drupalLogin($this->web_user);
$edit = array();
$edit['subject'] = $this->randomName(8);
- $edit['comment'] = $this->randomName(16);
+ $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
$this->drupalPost('node/' . $this->node->nid, $edit, t('Preview'));
// Check that the preview is displaying the title and body.
$this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".'));
$this->assertText($edit['subject'], t('Subject displayed.'));
- $this->assertText($edit['comment'], t('Comment displayed.'));
+ $this->assertText($edit['comment_body[' . $langcode . '][0][value]'], t('Comment displayed.'));
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.'));
- $this->assertFieldByName('comment', $edit['comment'], t('Comment field displayed.'));
+ $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.'));
}
/**
* Test comment edit and preview.
*/
function testCommentEditPreview() {
+ $langcode = LANGUAGE_NONE;
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'post comments without approval'));
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(TRUE);
@@ -444,23 +449,23 @@ class CommentPreviewTest extends CommentHelperCase {
$edit = array();
$edit['subject'] = $this->randomName(8);
- $edit['comment'] = $this->randomName(16);
+ $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
$edit['name'] = $web_user->name;
$edit['date'] = '2008-03-02 17:23 +0300';
$expected_date = format_date(strtotime($edit['date']));
- $comment = $this->postComment($this->node, $edit['subject'], $edit['comment'], TRUE);
+ $comment = $this->postComment($this->node, $edit['subject'], $edit['comment_body[' . $langcode . '][0][value]'], TRUE);
$this->drupalPost('comment/' . $comment->id . '/edit', $edit, t('Preview'));
// Check that the preview is displaying the subject, comment, author and date correctly.
$this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".'));
$this->assertText($edit['subject'], t('Subject displayed.'));
- $this->assertText($edit['comment'], t('Comment displayed.'));
+ $this->assertText($edit['comment_body[' . $langcode . '][0][value]'], t('Comment displayed.'));
$this->assertText($edit['name'], t('Author displayed.'));
$this->assertText($expected_date, t('Date displayed.'));
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.'));
- $this->assertFieldByName('comment', $edit['comment'], t('Comment field displayed.'));
+ $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.'));
$this->assertFieldByName('name', $edit['name'], t('Author field displayed.'));
$this->assertFieldByName('date', $edit['date'], t('Date field displayed.'));
}
diff --git a/modules/comment/comment.tpl.php b/modules/comment/comment.tpl.php
index ac5f431f7..314da57ca 100644
--- a/modules/comment/comment.tpl.php
+++ b/modules/comment/comment.tpl.php
@@ -18,6 +18,7 @@
* Preprocess functions can reformat it by calling format_date() with the
* desired parameters on the $comment->changed variable.
* - $new: New comment marker.
+ * - $permalink: Comment permalink.
* - $picture: Authors picture.
* - $signature: Authors signature.
* - $status: Comment status. Possible values are:
@@ -67,6 +68,7 @@
<?php print render($title_suffix); ?>
<div class="submitted">
+ <?php print $permalink; ?>
<?php
print t('Submitted by !username on !datetime.',
array('!username' => $author, '!datetime' => $created));
diff --git a/modules/forum/forum.test b/modules/forum/forum.test
index ae900307b..5a6b0f229 100644
--- a/modules/forum/forum.test
+++ b/modules/forum/forum.test
@@ -78,7 +78,9 @@ class ForumTestCase extends DrupalWebTestCase {
// 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'));
+ $edit = array();
+ $edit['comment_body[' . LANGUAGE_NONE . '][0][value]'] = $this->randomName();
+ $this->drupalPost("node/$node->nid", $edit, t('Save'));
$this->assertResponse(200);
// Test editing a forum topic that has a comment.
diff --git a/modules/search/search.test b/modules/search/search.test
index 11137c441..3c4f91a57 100644
--- a/modules/search/search.test
+++ b/modules/search/search.test
@@ -385,7 +385,9 @@ class SearchRankingTestCase extends DrupalWebTestCase {
$this->refreshVariables();
// Add a comment to one of the nodes.
- $edit = array('subject' => 'my comment title', 'comment' => 'some random comment');
+ $edit = array();
+ $edit['subject'] = 'my comment title';
+ $edit['comment_body[' . LANGUAGE_NONE . '][0][value]'] = 'some random comment';
$this->drupalGet('comment/reply/' . $nodes['comments'][1]->nid);
$this->drupalPost(NULL, $edit, t('Preview'));
$this->drupalPost(NULL, $edit, t('Save'));
@@ -520,18 +522,25 @@ class SearchCommentTestCase extends DrupalWebTestCase {
// Create a node.
$node = $this->drupalCreateNode(array('type' => 'article'));
// Post a comment using 'Full HTML' text format.
- $edit_comment = array(
- 'subject' => $this->randomName(2),
- 'comment' => '<h1>' . $comment_body . '</h1>',
- 'comment_format' => 2,
- );
+ $edit_comment = array();
+ $edit_comment['subject'] = $this->randomName(2);
+ $edit_comment['comment_body[' . LANGUAGE_NONE . '][0][value]'] = '<h1>' . $comment_body . '</h1>';
+ $edit_comment['comment_body[' . LANGUAGE_NONE . '][0][value_format]'] = 2;
$this->drupalPost('comment/reply/' . $node->nid, $edit_comment, t('Save'));
// Invoke search index update.
$this->drupalLogout();
$this->cronRun();
- // Search for $title.
+ // Search for the comment subject.
+ $edit = array(
+ 'search_block_form' => $edit_comment['subject'],
+ );
+ $this->drupalPost('', $edit, t('Search'));
+ $this->assertText($node->title[LANGUAGE_NONE][0]['value'], t('Node found in search results.'));
+ $this->assertText($edit_comment['subject'], t('Comment subject found in search results.'));
+
+ // Search for the comment body.
$edit = array(
'search_block_form' => $comment_body,
);
@@ -539,10 +548,9 @@ class SearchCommentTestCase extends DrupalWebTestCase {
$this->assertText($node->title[LANGUAGE_NONE][0]['value'], t('Node found in search results.'));
// Verify that comment is rendered using proper format.
- $this->assertText($edit_comment['subject'], t('Comment subject found in search results.'));
$this->assertText($comment_body, t('Comment body text found in search results.'));
$this->assertNoRaw(t('n/a'), t('HTML in comment body is not hidden.'));
- $this->assertNoRaw(check_plain($edit_comment['comment']), t('HTML in comment body is not escaped.'));
+ $this->assertNoRaw(check_plain($edit_comment['comment_body[' . LANGUAGE_NONE . '][0][value]']), t('HTML in comment body is not escaped.'));
// Hide comments.
$this->drupalLogin($this->admin_user);
diff --git a/modules/tracker/tracker.test b/modules/tracker/tracker.test
index bd67fda5a..7f71caf0c 100644
--- a/modules/tracker/tracker.test
+++ b/modules/tracker/tracker.test
@@ -74,7 +74,7 @@ class TrackerTest extends DrupalWebTestCase {
));
$comment = array(
'subject' => $this->randomName(),
- 'comment' => $this->randomName(20),
+ 'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
);
$this->drupalPost('comment/reply/' . $other_published_my_comment->nid, $comment, t('Save'));
@@ -134,7 +134,7 @@ class TrackerTest extends DrupalWebTestCase {
// Add a comment to the page.
$comment = array(
'subject' => $this->randomName(),
- 'comment' => $this->randomName(20),
+ 'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
);
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save')); // The new comment is automatically viewed by the current user.
@@ -146,7 +146,7 @@ class TrackerTest extends DrupalWebTestCase {
// Add another comment as other_user.
$comment = array(
'subject' => $this->randomName(),
- 'comment' => $this->randomName(20),
+ 'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
);
// If the comment is posted in the same second as the last one then Drupal
// can't tell a difference, so wait one second here.
@@ -179,7 +179,7 @@ class TrackerTest extends DrupalWebTestCase {
$this->drupalLogin($this->other_user);
$comment = array(
'subject' => $this->randomName(),
- 'comment' => $this->randomName(20),
+ 'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
);
$this->drupalPost('comment/reply/' . $nodes[3]->nid, $comment, t('Save'));
diff --git a/modules/trigger/trigger.test b/modules/trigger/trigger.test
index 382b7da1a..9bf1e5b01 100644
--- a/modules/trigger/trigger.test
+++ b/modules/trigger/trigger.test
@@ -255,7 +255,7 @@ class TriggerOtherTestCase extends DrupalWebTestCase {
$node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
$edit = array();
$edit['subject'] = $this->randomName(10);
- $edit['comment'] = $this->randomName(10) . ' ' . $this->randomName(10);
+ $edit['comment_body[' . LANGUAGE_NONE . '][0][value]'] = $this->randomName(10) . ' ' . $this->randomName(10);
$this->drupalGet('comment/reply/' . $node->nid);
$this->drupalPost(NULL, $edit, t('Save'));
diff --git a/modules/user/user.test b/modules/user/user.test
index 494d3e1fb..65408397d 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -537,10 +537,11 @@ class UserCancelTestCase extends DrupalWebTestCase {
$node = $this->drupalCreateNode(array('uid' => $account->uid));
// Create comment.
- $edit = array(
- 'subject' => $this->randomString(),
- 'comment' => $this->randomString(),
- );
+ $langcode = LANGUAGE_NONE;
+ $edit = array();
+ $edit['subject'] = $this->randomName(8);
+ $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
+
$this->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview'));
$this->drupalPost(NULL, array(), t('Save'));
$this->assertText(t('Your comment has been posted.'));