core security update
This commit is contained in:
@@ -189,7 +189,7 @@ function field_create_field($field) {
|
||||
}
|
||||
|
||||
// Clear caches
|
||||
field_cache_clear(TRUE);
|
||||
field_cache_clear();
|
||||
|
||||
// Invoke external hooks after the cache is cleared for API consistency.
|
||||
module_invoke_all('field_create_field', $field);
|
||||
@@ -288,7 +288,7 @@ function field_update_field($field) {
|
||||
drupal_write_record('field_config', $field, $primary_key);
|
||||
|
||||
// Clear caches
|
||||
field_cache_clear(TRUE);
|
||||
field_cache_clear();
|
||||
|
||||
// Invoke external hooks after the cache is cleared for API consistency.
|
||||
module_invoke_all('field_update_field', $field, $prior_field, $has_data);
|
||||
@@ -430,7 +430,7 @@ function field_delete_field($field_name) {
|
||||
->execute();
|
||||
|
||||
// Clear the cache.
|
||||
field_cache_clear(TRUE);
|
||||
field_cache_clear();
|
||||
|
||||
module_invoke_all('field_delete_field', $field);
|
||||
}
|
||||
|
@@ -11,8 +11,8 @@ dependencies[] = field_sql_storage
|
||||
required = TRUE
|
||||
stylesheets[all][] = theme/field.css
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
; Information added by Drupal.org packaging script on 2016-10-05
|
||||
version = "7.51"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
datestamp = "1475694174"
|
||||
|
||||
|
@@ -612,10 +612,12 @@ class FieldInfo {
|
||||
// Fill in default values.
|
||||
$display += array(
|
||||
'label' => 'above',
|
||||
'type' => $field_type_info['default_formatter'],
|
||||
'settings' => array(),
|
||||
'weight' => 0,
|
||||
);
|
||||
if (empty($display['type'])) {
|
||||
$display['type'] = $field_type_info['default_formatter'];
|
||||
}
|
||||
if ($display['type'] != 'hidden') {
|
||||
$formatter_type_info = field_info_formatter_types($display['type']);
|
||||
// Fall back to default formatter if formatter type is not available.
|
||||
|
@@ -467,6 +467,27 @@ function field_update_7003() {
|
||||
// Empty update to force a rebuild of the registry.
|
||||
}
|
||||
|
||||
/**
|
||||
* Grant the new "administer fields" permission to trusted users.
|
||||
*/
|
||||
function field_update_7004() {
|
||||
// Assign the permission to anyone that already has a trusted core permission
|
||||
// that would have previously let them administer fields on an entity type.
|
||||
$rids = array();
|
||||
$permissions = array(
|
||||
'administer site configuration',
|
||||
'administer content types',
|
||||
'administer users',
|
||||
);
|
||||
foreach ($permissions as $permission) {
|
||||
$rids = array_merge($rids, array_keys(user_roles(FALSE, $permission)));
|
||||
}
|
||||
$rids = array_unique($rids);
|
||||
foreach ($rids as $rid) {
|
||||
_update_7000_user_role_grant_permissions($rid, array('administer fields'), 'field');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-7.x-extra".
|
||||
*/
|
||||
|
@@ -316,6 +316,21 @@ function field_help($path, $arg) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function field_permission() {
|
||||
return array(
|
||||
'administer fields' => array(
|
||||
'title' => t('Administer fields'),
|
||||
'description' => t('Additional permissions are required based on what the fields are attached to (for example, <a href="@url">administer content types</a> to manage fields attached to content).', array(
|
||||
'@url' => '#module-node',
|
||||
)),
|
||||
'restrict access' => TRUE,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = field
|
||||
files[] = field_sql_storage.test
|
||||
required = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
; Information added by Drupal.org packaging script on 2016-10-05
|
||||
version = "7.51"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
datestamp = "1475694174"
|
||||
|
||||
|
@@ -223,7 +223,17 @@ function _field_sql_storage_schema($field) {
|
||||
foreach ($field['indexes'] as $index_name => $columns) {
|
||||
$real_name = _field_sql_storage_indexname($field['field_name'], $index_name);
|
||||
foreach ($columns as $column_name) {
|
||||
$current['indexes'][$real_name][] = _field_sql_storage_columnname($field['field_name'], $column_name);
|
||||
// Indexes can be specified as either a column name or an array with
|
||||
// column name and length. Allow for either case.
|
||||
if (is_array($column_name)) {
|
||||
$current['indexes'][$real_name][] = array(
|
||||
_field_sql_storage_columnname($field['field_name'], $column_name[0]),
|
||||
$column_name[1],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$current['indexes'][$real_name][] = _field_sql_storage_columnname($field['field_name'], $column_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +342,17 @@ function field_sql_storage_field_storage_update_field($field, $prior_field, $has
|
||||
$real_name = _field_sql_storage_indexname($field['field_name'], $name);
|
||||
$real_columns = array();
|
||||
foreach ($columns as $column_name) {
|
||||
$real_columns[] = _field_sql_storage_columnname($field['field_name'], $column_name);
|
||||
// Indexes can be specified as either a column name or an array with
|
||||
// column name and length. Allow for either case.
|
||||
if (is_array($column_name)) {
|
||||
$real_columns[] = array(
|
||||
_field_sql_storage_columnname($field['field_name'], $column_name[0]),
|
||||
$column_name[1],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$real_columns[] = _field_sql_storage_columnname($field['field_name'], $column_name);
|
||||
}
|
||||
}
|
||||
db_add_index($table, $real_name, $real_columns);
|
||||
db_add_index($revision_table, $real_name, $real_columns);
|
||||
|
@@ -355,14 +355,14 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
field_attach_insert('test_entity', $entity);
|
||||
|
||||
// Add an index
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value' => array('value')));
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value' => array(array('value', 255))));
|
||||
field_update_field($field);
|
||||
foreach ($tables as $table) {
|
||||
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), format_string("Index on value created in %table", array('%table' => $table)));
|
||||
}
|
||||
|
||||
// Add a different index, removing the existing custom one.
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value_format' => array('value', 'format')));
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value_format' => array(array('value', 127), array('format', 127))));
|
||||
field_update_field($field);
|
||||
foreach ($tables as $table) {
|
||||
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), format_string("Index on value_format created in %table", array('%table' => $table)));
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = field
|
||||
dependencies[] = options
|
||||
files[] = tests/list.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
; Information added by Drupal.org packaging script on 2016-10-05
|
||||
version = "7.51"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
datestamp = "1475694174"
|
||||
|
||||
|
@@ -212,7 +212,7 @@ class ListFieldUITestCase extends FieldTestCase {
|
||||
parent::setUp('field_test', 'field_ui');
|
||||
|
||||
// Create test user.
|
||||
$admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy'));
|
||||
$admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy', 'administer fields'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Create content type, with underscores.
|
||||
|
@@ -5,8 +5,8 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
; Information added by Drupal.org packaging script on 2016-10-05
|
||||
version = "7.51"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
datestamp = "1475694174"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = field
|
||||
files[] = number.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
; Information added by Drupal.org packaging script on 2016-10-05
|
||||
version = "7.51"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
datestamp = "1475694174"
|
||||
|
||||
|
@@ -188,7 +188,7 @@ function number_field_formatter_info() {
|
||||
'label' => t('Default'),
|
||||
'field types' => array('number_integer'),
|
||||
'settings' => array(
|
||||
'thousand_separator' => ' ',
|
||||
'thousand_separator' => '',
|
||||
// The 'decimal_separator' and 'scale' settings are not configurable
|
||||
// through the UI, and will therefore keep their default values. They
|
||||
// are only present so that the 'number_integer' and 'number_decimal'
|
||||
@@ -202,7 +202,7 @@ function number_field_formatter_info() {
|
||||
'label' => t('Default'),
|
||||
'field types' => array('number_decimal', 'number_float'),
|
||||
'settings' => array(
|
||||
'thousand_separator' => ' ',
|
||||
'thousand_separator' => '',
|
||||
'decimal_separator' => '.',
|
||||
'scale' => 2,
|
||||
'prefix_suffix' => TRUE,
|
||||
@@ -222,6 +222,8 @@ function number_field_formatter_settings_form($field, $instance, $view_mode, $fo
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
|
||||
$element = array();
|
||||
|
||||
if ($display['type'] == 'number_decimal' || $display['type'] == 'number_integer') {
|
||||
$options = array(
|
||||
'' => t('<none>'),
|
||||
|
@@ -23,7 +23,7 @@ class NumberFieldTestCase extends DrupalWebTestCase {
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('field_test');
|
||||
$this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer content types'));
|
||||
$this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer content types', 'administer fields'));
|
||||
$this->drupalLogin($this->web_user);
|
||||
}
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = field
|
||||
files[] = options.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
; Information added by Drupal.org packaging script on 2016-10-05
|
||||
version = "7.51"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
datestamp = "1475694174"
|
||||
|
||||
|
@@ -185,6 +185,7 @@ function _options_properties($type, $multiple, $required, $has_value) {
|
||||
$base = array(
|
||||
'filter_xss' => FALSE,
|
||||
'strip_tags' => FALSE,
|
||||
'strip_tags_and_unescape' => FALSE,
|
||||
'empty_option' => FALSE,
|
||||
'optgroups' => FALSE,
|
||||
);
|
||||
@@ -195,7 +196,7 @@ function _options_properties($type, $multiple, $required, $has_value) {
|
||||
case 'select':
|
||||
$properties = array(
|
||||
// Select boxes do not support any HTML tag.
|
||||
'strip_tags' => TRUE,
|
||||
'strip_tags_and_unescape' => TRUE,
|
||||
'optgroups' => TRUE,
|
||||
);
|
||||
if ($multiple) {
|
||||
@@ -271,9 +272,16 @@ function _options_prepare_options(&$options, $properties) {
|
||||
_options_prepare_options($options[$value], $properties);
|
||||
}
|
||||
else {
|
||||
// The 'strip_tags' option is deprecated. Use 'strip_tags_and_unescape'
|
||||
// when plain text is required (and where the output will be run through
|
||||
// check_plain() before being inserted back into HTML) or 'filter_xss'
|
||||
// when HTML is required.
|
||||
if ($properties['strip_tags']) {
|
||||
$options[$value] = strip_tags($label);
|
||||
}
|
||||
if ($properties['strip_tags_and_unescape']) {
|
||||
$options[$value] = decode_entities(strip_tags($label));
|
||||
}
|
||||
if ($properties['filter_xss']) {
|
||||
$options[$value] = field_filter_xss($label);
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
'cardinality' => 1,
|
||||
'settings' => array(
|
||||
// Make sure that 0 works as an option.
|
||||
'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>'),
|
||||
'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>', 3 => 'Some HTML encoded markup with < & >'),
|
||||
),
|
||||
);
|
||||
$this->card_1 = field_create_field($this->card_1);
|
||||
@@ -54,7 +54,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->bool = field_create_field($this->bool);
|
||||
|
||||
// Create a web user.
|
||||
$this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content'));
|
||||
$this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer fields'));
|
||||
$this->drupalLogin($this->web_user);
|
||||
}
|
||||
|
||||
@@ -233,6 +233,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 1);
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 2);
|
||||
$this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.');
|
||||
$this->assertRaw('Some HTML encoded markup with < & >', 'HTML entities in option text were properly handled and not double-encoded');
|
||||
|
||||
// Submit form: select invalid 'none' option.
|
||||
$edit = array("card_1[$langcode]" => '_none');
|
||||
@@ -459,7 +460,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->assertNoFieldChecked("edit-bool-$langcode");
|
||||
|
||||
// Create admin user.
|
||||
$admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy'));
|
||||
$admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy', 'administer fields'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Create a test field instance.
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = field
|
||||
files[] = text.test
|
||||
required = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
; Information added by Drupal.org packaging script on 2016-10-05
|
||||
version = "7.51"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
datestamp = "1475694174"
|
||||
|
||||
|
@@ -223,11 +223,13 @@ function text_field_formatter_settings_form($field, $instance, $view_mode, $form
|
||||
|
||||
if (strpos($display['type'], '_trimmed') !== FALSE) {
|
||||
$element['trim_length'] = array(
|
||||
'#title' => t('Trim length'),
|
||||
'#title' => t('Trimmed limit'),
|
||||
'#type' => 'textfield',
|
||||
'#field_suffix' => t('characters'),
|
||||
'#size' => 10,
|
||||
'#default_value' => $settings['trim_length'],
|
||||
'#element_validate' => array('element_validate_integer_positive'),
|
||||
'#description' => t('If the summary is not set, the trimmed %label field will be shorter than this character limit.', array('%label' => $instance['label'])),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
}
|
||||
@@ -245,7 +247,7 @@ function text_field_formatter_settings_summary($field, $instance, $view_mode) {
|
||||
$summary = '';
|
||||
|
||||
if (strpos($display['type'], '_trimmed') !== FALSE) {
|
||||
$summary = t('Trim length') . ': ' . check_plain($settings['trim_length']);
|
||||
$summary = t('Trimmed limit: @trim_length characters', array('@trim_length' => $settings['trim_length']));
|
||||
}
|
||||
|
||||
return $summary;
|
||||
|
@@ -424,6 +424,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
|
||||
'administer content types',
|
||||
'access administration pages',
|
||||
'bypass node access',
|
||||
'administer fields',
|
||||
filter_permission_name($full_html_format),
|
||||
));
|
||||
$this->translator = $this->drupalCreateUser(array('create article content', 'edit own article content', 'translate content'));
|
||||
|
@@ -6,8 +6,8 @@ files[] = field_test.entity.inc
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
; Information added by Drupal.org packaging script on 2016-10-05
|
||||
version = "7.51"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
datestamp = "1475694174"
|
||||
|
||||
|
Reference in New Issue
Block a user