security update core+modules
This commit is contained in:
@@ -98,13 +98,14 @@ function comment_admin_overview($form, &$form_state, $arg) {
|
||||
// Remove the first node title from the node_titles array and attach to
|
||||
// the comment.
|
||||
$comment->node_title = array_shift($node_titles);
|
||||
$comment_body = field_get_items('comment', $comment, 'comment_body');
|
||||
$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_body[LANGUAGE_NONE][0]['value'], 128)), 'fragment' => 'comment-' . $comment->cid),
|
||||
'#options' => array('attributes' => array('title' => truncate_utf8($comment_body[0]['value'], 128)), 'fragment' => 'comment-' . $comment->cid),
|
||||
),
|
||||
),
|
||||
'author' => theme('username', array('account' => $comment)),
|
||||
|
@@ -8,3 +8,9 @@ files[] = comment.module
|
||||
files[] = comment.test
|
||||
configure = admin/content/comment
|
||||
stylesheets[all][] = comment.css
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -152,7 +152,7 @@ function comment_node_type_load($name) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity URI callback.
|
||||
* Implements callback_entity_info_uri().
|
||||
*/
|
||||
function comment_uri($comment) {
|
||||
return array(
|
||||
@@ -490,7 +490,7 @@ function comment_permalink($cid) {
|
||||
// Return the node view, this will show the correct comment in context.
|
||||
return menu_execute_active_handler('node/' . $node->nid, FALSE);
|
||||
}
|
||||
drupal_not_found();
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -993,12 +993,7 @@ function comment_build_content($comment, $node, $view_mode = 'full', $langcode =
|
||||
$comment->content = array();
|
||||
|
||||
// Allow modules to change the view mode.
|
||||
$context = array(
|
||||
'entity_type' => 'comment',
|
||||
'entity' => $comment,
|
||||
'langcode' => $langcode,
|
||||
);
|
||||
drupal_alter('entity_view_mode', $view_mode, $context);
|
||||
$view_mode = key(entity_view_mode_prepare('comment', array($comment->cid => $comment), $view_mode, $langcode));
|
||||
|
||||
// Build fields content.
|
||||
field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode, $langcode);
|
||||
@@ -1108,17 +1103,26 @@ function comment_links($comment, $node) {
|
||||
* An array in the format expected by drupal_render().
|
||||
*/
|
||||
function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0, $langcode = NULL) {
|
||||
field_attach_prepare_view('comment', $comments, $view_mode, $langcode);
|
||||
entity_prepare_view('comment', $comments, $langcode);
|
||||
$build = array();
|
||||
$entities_by_view_mode = entity_view_mode_prepare('comment', $comments, $view_mode, $langcode);
|
||||
foreach ($entities_by_view_mode as $entity_view_mode => $entities) {
|
||||
field_attach_prepare_view('comment', $entities, $entity_view_mode, $langcode);
|
||||
entity_prepare_view('comment', $entities, $langcode);
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
$build[$entity->cid] = comment_view($entity, $node, $entity_view_mode, $langcode);
|
||||
}
|
||||
}
|
||||
|
||||
$build = array(
|
||||
'#sorted' => TRUE,
|
||||
);
|
||||
foreach ($comments as $comment) {
|
||||
$build[$comment->cid] = comment_view($comment, $node, $view_mode, $langcode);
|
||||
$build[$comment->cid]['#weight'] = $weight;
|
||||
$weight++;
|
||||
}
|
||||
// Sort here, to preserve the input order of the entities that were passed to
|
||||
// this function.
|
||||
uasort($build, 'element_sort');
|
||||
$build['#sorted'] = TRUE;
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
@@ -2041,7 +2045,8 @@ function comment_form($form, &$form_state, $comment) {
|
||||
|
||||
// Attach fields.
|
||||
$comment->node_type = 'comment_node_' . $node->type;
|
||||
field_attach_form('comment', $comment, $form, $form_state);
|
||||
$langcode = entity_language('comment', $comment);
|
||||
field_attach_form('comment', $comment, $form, $form_state, $langcode);
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -2066,7 +2071,8 @@ function comment_preview($comment) {
|
||||
$node = node_load($comment->nid);
|
||||
|
||||
if (!form_get_errors()) {
|
||||
$comment->format = $comment->comment_body[LANGUAGE_NONE][0]['format'];
|
||||
$comment_body = field_get_items('comment', $comment, 'comment_body');
|
||||
$comment->format = $comment_body[0]['format'];
|
||||
// Attach the user and time information.
|
||||
if (!empty($comment->name)) {
|
||||
$account = user_load_by_name($comment->name);
|
||||
@@ -2190,7 +2196,9 @@ function comment_submit($comment) {
|
||||
// 1) Filter it into HTML
|
||||
// 2) Strip out all HTML tags
|
||||
// 3) Convert entities back to plain-text.
|
||||
$comment_body = $comment->comment_body[LANGUAGE_NONE][0];
|
||||
$field = field_info_field('comment_body');
|
||||
$langcode = field_is_translatable('comment', $field) ? entity_language('comment', $comment) : LANGUAGE_NONE;
|
||||
$comment_body = $comment->comment_body[$langcode][0];
|
||||
if (isset($comment_body['format'])) {
|
||||
$comment_text = check_markup($comment_body['value'], $comment_body['format']);
|
||||
}
|
||||
@@ -2284,15 +2292,23 @@ function template_preprocess_comment(&$variables) {
|
||||
$variables['comment'] = $comment;
|
||||
$variables['node'] = $node;
|
||||
$variables['author'] = theme('username', array('account' => $comment));
|
||||
|
||||
$variables['created'] = format_date($comment->created);
|
||||
$variables['changed'] = format_date($comment->changed);
|
||||
|
||||
// Avoid calling format_date() twice on the same timestamp.
|
||||
if ($comment->changed == $comment->created) {
|
||||
$variables['changed'] = $variables['created'];
|
||||
}
|
||||
else {
|
||||
$variables['changed'] = format_date($comment->changed);
|
||||
}
|
||||
|
||||
$variables['new'] = !empty($comment->new) ? t('new') : '';
|
||||
$variables['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : '';
|
||||
$variables['signature'] = $comment->signature;
|
||||
|
||||
$uri = entity_uri('comment', $comment);
|
||||
$uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark'));
|
||||
$uri['options'] += array('attributes' => array('class' => array('permalink'), 'rel' => 'bookmark'));
|
||||
|
||||
$variables['title'] = l($comment->subject, $uri['path'], $uri['options']);
|
||||
$variables['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
|
||||
@@ -2591,7 +2607,7 @@ function comment_unpublish_action($comment, $context = array()) {
|
||||
/**
|
||||
* Unpublishes a comment if it contains certain keywords.
|
||||
*
|
||||
* @param $comment
|
||||
* @param object $comment
|
||||
* Comment object to modify.
|
||||
* @param array $context
|
||||
* Array with components:
|
||||
@@ -2603,10 +2619,13 @@ function comment_unpublish_action($comment, $context = array()) {
|
||||
* @see comment_unpublish_by_keyword_action_submit()
|
||||
*/
|
||||
function comment_unpublish_by_keyword_action($comment, $context) {
|
||||
$node = node_load($comment->nid);
|
||||
$build = comment_view($comment, $node);
|
||||
$text = drupal_render($build);
|
||||
foreach ($context['keywords'] as $keyword) {
|
||||
$text = drupal_render($comment);
|
||||
if (strpos($text, $keyword) !== FALSE) {
|
||||
$comment->status = COMMENT_NOT_PUBLISHED;
|
||||
comment_save($comment);
|
||||
watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));
|
||||
break;
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||
function setUp() {
|
||||
parent::setUp('comment', 'search');
|
||||
// Create users and test node.
|
||||
$this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer blocks'));
|
||||
$this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer blocks', 'administer actions'));
|
||||
$this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'edit own comments'));
|
||||
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid));
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||
$mode_text = 'required';
|
||||
break;
|
||||
}
|
||||
$this->setCommentSettings('comment_preview', $mode, 'Comment preview ' . $mode_text . '.');
|
||||
$this->setCommentSettings('comment_preview', $mode, format_string('Comment preview @mode_text.', array('@mode_text' => $mode_text)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||
* Anonymous level.
|
||||
*/
|
||||
function setCommentAnonymous($level) {
|
||||
$this->setCommentSettings('comment_anonymous', $level, 'Anonymous commenting set to level ' . $level . '.');
|
||||
$this->setCommentSettings('comment_anonymous', $level, format_string('Anonymous commenting set to level @level.', array('@level' => $level)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +185,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||
* Comments per page value.
|
||||
*/
|
||||
function setCommentsPerPage($number) {
|
||||
$this->setCommentSettings('comment_default_per_page', $number, 'Number of comments per page set to ' . $number . '.');
|
||||
$this->setCommentSettings('comment_default_per_page', $number, format_string('Number of comments per page set to @number.', array('@number' => $number)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +201,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||
function setCommentSettings($name, $value, $message) {
|
||||
variable_set($name . '_article', $value);
|
||||
// Display status message.
|
||||
$this->assertTrue(TRUE, $message);
|
||||
$this->pass($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +273,7 @@ class CommentInterfaceTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_DISABLED);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(FALSE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Post comment #1 without subject or preview.
|
||||
@@ -583,7 +583,7 @@ class CommentInterfaceTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_DISABLED);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(FALSE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Creates a second user to post comments.
|
||||
@@ -954,7 +954,7 @@ class CommentPreviewTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_OPTIONAL);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Login as web user and add a signature and a user picture.
|
||||
@@ -1000,7 +1000,7 @@ class CommentPreviewTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_OPTIONAL);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
|
||||
$edit = array();
|
||||
$edit['subject'] = $this->randomName(8);
|
||||
@@ -1238,7 +1238,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
|
||||
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.');
|
||||
|
||||
// Set comments to one per page so that we are able to test paging without
|
||||
// needing to insert large numbers of comments.
|
||||
@@ -1279,7 +1279,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
// If we switch to threaded mode, the replies on the oldest comment
|
||||
// should be bumped to the first page and comment 6 should be bumped
|
||||
// to the second page.
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.');
|
||||
$this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0)));
|
||||
$this->assertTrue($this->commentExists($reply, TRUE), 'In threaded mode, reply appears on page 1.');
|
||||
$this->assertFalse($this->commentExists($comments[1]), 'In threaded mode, comment 2 has been bumped off of page 1.');
|
||||
@@ -1339,7 +1339,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
// - 2
|
||||
// - 5
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.');
|
||||
|
||||
$expected_order = array(
|
||||
0,
|
||||
@@ -1353,7 +1353,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertCommentOrder($comments, $expected_order);
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.');
|
||||
|
||||
$expected_order = array(
|
||||
0,
|
||||
@@ -1435,7 +1435,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
// - 2
|
||||
// - 5
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.');
|
||||
|
||||
$expected_pages = array(
|
||||
1 => 5, // Page of comment 5
|
||||
@@ -1453,7 +1453,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
$this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
|
||||
}
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.');
|
||||
|
||||
$expected_pages = array(
|
||||
1 => 5, // Page of comment 5
|
||||
@@ -1509,7 +1509,7 @@ class CommentNodeAccessTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_DISABLED);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Post comment.
|
||||
@@ -1973,6 +1973,41 @@ class CommentActionsTestCase extends CommentHelperCase {
|
||||
$this->clearWatchdog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the unpublish comment by keyword action.
|
||||
*/
|
||||
public function testCommentUnpublishByKeyword() {
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$callback = 'comment_unpublish_by_keyword_action';
|
||||
$hash = drupal_hash_base64($callback);
|
||||
$comment_text = $keywords = $this->randomName();
|
||||
$edit = array(
|
||||
'actions_label' => $callback,
|
||||
'keywords' => $keywords,
|
||||
);
|
||||
|
||||
$this->drupalPost("admin/config/system/actions/configure/$hash", $edit, t('Save'));
|
||||
|
||||
$action = db_query("SELECT aid, type, callback, parameters, label FROM {actions} WHERE callback = :callback", array(':callback' => $callback))->fetchObject();
|
||||
|
||||
$this->assertTrue($action, 'The action could be loaded.');
|
||||
|
||||
$comment = $this->postComment($this->node, $comment_text, $this->randomName());
|
||||
|
||||
// Load the full comment so that status is available.
|
||||
$comment = comment_load($comment->id);
|
||||
|
||||
$this->assertTrue($comment->status == COMMENT_PUBLISHED, 'The comment status was set to published.');
|
||||
|
||||
comment_unpublish_by_keyword_action($comment, array('keywords' => array($keywords)));
|
||||
|
||||
// We need to make sure that the comment has been saved with status
|
||||
// unpublished.
|
||||
$this->assertEqual(comment_load($comment->cid)->status, COMMENT_NOT_PUBLISHED, 'Comment was unpublished.');
|
||||
$this->assertWatchdogMessage('Unpublished comment %subject.', array('%subject' => $comment->subject), 'Found watchdog message.');
|
||||
$this->clearWatchdog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that a watchdog message has been entered.
|
||||
*
|
||||
@@ -2126,7 +2161,7 @@ class CommentThreadingTestCase extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_DISABLED);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Create a node.
|
||||
|
Reference in New Issue
Block a user