security updates of unpatched modules

This commit is contained in:
Bachir Soussi Chiadmi
2016-10-25 16:23:00 +02:00
parent 610760bedf
commit f6f7fd575f
133 changed files with 5598 additions and 2574 deletions

View File

@@ -13,10 +13,10 @@ abstract class FlagTestCaseBase extends DrupalWebTestCase {
/**
* Helper to create a flag from an array of data and clear caches etc.
*
* @param $flag_data
* @param array $flag_data
* An array of flag data.
*
* @return
* @return flag_flag
* The flag object.
*/
function createFlag($flag_data) {
@@ -1656,3 +1656,129 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
}
}
/**
* Verifies the optimization for comment viewing.
*/
class FlagCommentOptimizationTestCase extends FlagTestCaseBase {
/**
* Implements getInfo().
*/
public static function getInfo() {
return array(
'name' => 'Comment view optimization',
'description' => 'Tests that loading of flagging records when viewing all comments on a node works correctly.',
'group' => 'Flag',
);
}
/**
* Implements setUp().
*/
function setUp() {
parent::setUp(array(
'flag',
'comment',
'flag_comment_flag_test',
));
$flag_data = array(
'entity_type' => 'comment',
'name' => 'test_flag',
'title' => 'Test Flag',
'global' => 0,
'types' => array(),
'flag_short' => 'Flag this item',
'flag_long' => '',
'flag_message' => '',
'unflag_short' => 'Unflag this item',
'unflag_long' => '',
'unflag_message' => '',
'unflag_denied_text' => 'You may not unflag this item',
'link_type' => 'normal',
'weight' => 0,
'show_on_form' => 0,
'access_author' => '',
'show_contextual_link' => 0,
'show_in_links' => array(
'full' => 1,
'teaser' => 1,
),
'i18n' => 0,
'api_version' => 3,
);
$this->flag = $this->createFlag($flag_data);
// Set up comments on article nodes.
variable_set('comment_form_location_article', COMMENT_FORM_BELOW);
// Create test user who can flag and unflag.
$this->user = $this->drupalCreateUser(array(
'access comments',
'post comments',
'flag test_flag',
'unflag test_flag',
));
$this->drupalLogin($this->user);
// Create an article node.
$title = $this->randomName(8);
$node = array(
'title' => $title,
'body' => array(LANGUAGE_NONE => array(array('value' => $this->randomName(32)))),
'uid' => $this->user->uid,
'type' => 'article',
'is_new' => TRUE,
'comment' => COMMENT_NODE_OPEN,
);
$node = node_submit((object) $node);
node_save($node);
$this->nid = $node->nid;
// Create some comments on the node.
$this->cids = array();
foreach (range(1, 10) as $i) {
$comment = (object) array(
'cid' => NULL,
'nid' => $node->nid,
'pid' => 0,
'uid' => $this->user->uid,
'status' => COMMENT_PUBLISHED,
'subject' => $this->randomName(),
'language' => LANGUAGE_NONE,
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
);
comment_save($comment);
$this->cids[$comment->cid] = $comment->cid;
}
// Flag one comment.
$this->flag->flag('flag', reset($this->cids));
}
/**
* Test viewing multiple comments on a node is optimized.
*/
function testCommentView() {
// View the node.
$this->drupalGet('node/' . $this->nid);
// Inspect the tracking variable.
// Hooks in the flag_comment_flag_test module will have populated this with
// data at various points in the lifecycle of the loaded page.
$tracking_variable = variable_get('flag_comment_flag_test_user_flags_cache_tracking', array());
$this->assertNull($tracking_variable['hook_comment_load'], "The flag_get_user_flags() static cache is empty when the comments are being loaded.");
// The test module's hook_entity_view() runs after flag's implementation, so
// for the first comment view, the cache should be fully populated: all
// comments should have an entry.
foreach ($this->cids as $cid) {
$this->assertNotNull($tracking_variable['hook_entity_view_1'][$this->user->uid][0]['comment'][$cid], "The static cache contained data for comment $cid when comment 1 was being viewed.");
}
}
}

View File

@@ -0,0 +1,13 @@
name = Flag Comment Flag Test
description = Test module for comment flags.
dependencies[] = flag
dependencies[] = comment
core = 7.x
hidden = TRUE
; Information added by Drupal.org packaging script on 2016-09-23
version = "7.x-3.9"
core = "7.x"
project = "flag"
datestamp = "1474619065"

View File

@@ -0,0 +1,41 @@
<?php
/**
* @file flag_comment_flag_test.module
* Test module for comment flags.
*/
/**
* Implements hook_comment_load().
*
* This is only called once when viewing a node with comments, and before
* hook_entity_view() is invoked. We use this to check the initial state of the
* cache.
*/
function flag_comment_flag_test_comment_load($comments) {
$flag_get_user_flags_cache = drupal_static('flag_get_user_flags');
// Store the value of the flag_get_user_flags() static cache in the variable,
// so the test can retrieve it.
$tracking_variable = variable_get('flag_comment_flag_test_user_flags_cache_tracking', array());
$tracking_variable['hook_comment_load'] = $flag_get_user_flags_cache;
variable_set('flag_comment_flag_test_user_flags_cache_tracking', $tracking_variable);
}
/**
* Implements hook_entity_view().
*
* Use hook_entity_view() rather than hook_comment_view() so we are in the same
* invocation as flag_entity_view().
*/
function flag_comment_flag_test_entity_view($entity, $type, $view_mode, $langcode) {
if ($type == 'comment') {
$flag_get_user_flags_cache = drupal_static('flag_get_user_flags');
// Store the value of the flag_get_user_flags() static cache in the variable,
// so the test can retrieve it.
$tracking_variable = variable_get('flag_comment_flag_test_user_flags_cache_tracking', array());
$tracking_variable['hook_entity_view_' . $entity->cid] = $flag_get_user_flags_cache;
variable_set('flag_comment_flag_test_user_flags_cache_tracking', $tracking_variable);
}
}

View File

@@ -4,9 +4,9 @@ dependencies[] = flag
core = 7.x
hidden = TRUE
; Information added by Drupal.org packaging script on 2015-03-02
version = "7.x-3.6"
; Information added by Drupal.org packaging script on 2016-09-23
version = "7.x-3.9"
core = "7.x"
project = "flag"
datestamp = "1425327793"
datestamp = "1474619065"

View File

@@ -5,9 +5,9 @@ dependencies[] = rules
core = 7.x
hidden = TRUE
; Information added by Drupal.org packaging script on 2015-03-02
version = "7.x-3.6"
; Information added by Drupal.org packaging script on 2016-09-23
version = "7.x-3.9"
core = "7.x"
project = "flag"
datestamp = "1425327793"
datestamp = "1474619065"

View File

@@ -10,9 +10,9 @@
*
* Hook implementations should call this with their hook name and parameters.
*
* @param $hook_name
* @param string $hook_name
* The name of the hook invoked.
* @param $function_parameters
* @param array $function_parameters
* The array of parameters the hook received.
* @param $flagging
* (optional) The flagging entity that the hook received. If this is given,

View File

@@ -5,9 +5,9 @@ dependencies[] = flag
package = Flags
hidden = TRUE
; Information added by Drupal.org packaging script on 2015-03-02
version = "7.x-3.6"
; Information added by Drupal.org packaging script on 2016-09-23
version = "7.x-3.9"
core = "7.x"
project = "flag"
datestamp = "1425327793"
datestamp = "1474619065"