Update to Drupal 8.2.6. For more information, see https://www.drupal.org/project/drupal/releases/8.2.6
This commit is contained in:
parent
db56c09587
commit
f1e72395cb
588 changed files with 26857 additions and 2777 deletions
|
|
@ -49,10 +49,6 @@ views.argument_default.user:
|
|||
type: boolean
|
||||
label: 'Also look for a node and use the node author'
|
||||
|
||||
views.argument_default.current_user:
|
||||
type: boolean
|
||||
label: 'User ID from logged in user'
|
||||
|
||||
views_field_user:
|
||||
type: views_field
|
||||
mapping:
|
||||
|
|
@ -102,3 +98,7 @@ views.filter.user_permissions:
|
|||
views.filter.user_roles:
|
||||
type: views.filter.many_to_one
|
||||
label: 'Role'
|
||||
|
||||
views.filter_value.user_current:
|
||||
type: views.filter_value.boolean
|
||||
label: 'Current user'
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ migration_dependencies:
|
|||
required:
|
||||
- d7_user_role
|
||||
optional:
|
||||
- d7_field_instance
|
||||
- d7_file
|
||||
- language
|
||||
- default_language
|
||||
|
|
|
|||
|
|
@ -3,19 +3,12 @@
|
|||
namespace Drupal\user\Plugin\migrate;
|
||||
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\Migration;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\CckMigration;
|
||||
|
||||
/**
|
||||
* Plugin class for Drupal 7 user migrations dealing with fields and profiles.
|
||||
*/
|
||||
class User extends Migration {
|
||||
|
||||
/**
|
||||
* Flag indicating whether the CCK data has been filled already.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $init = FALSE;
|
||||
class User extends CckMigration {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
@ -33,7 +26,21 @@ class User extends Migration {
|
|||
$field_migration = $this->migrationPluginManager->createStubMigration($definition);
|
||||
foreach ($field_migration->getSourcePlugin() as $row) {
|
||||
$field_name = $row->getSourceProperty('field_name');
|
||||
$this->process[$field_name] = $field_name;
|
||||
$field_type = $row->getSourceProperty('type');
|
||||
if (empty($field_type)) {
|
||||
continue;
|
||||
}
|
||||
if ($this->cckPluginManager->hasDefinition($field_type)) {
|
||||
if (!isset($this->cckPluginCache[$field_type])) {
|
||||
$this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($field_type, [], $this);
|
||||
}
|
||||
$info = $row->getSource();
|
||||
$this->cckPluginCache[$field_type]
|
||||
->processCckFieldValues($this, $field_name, $info);
|
||||
}
|
||||
else {
|
||||
$this->process[$field_name] = $field_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,119 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- user
|
||||
id: test_filter_current_user
|
||||
label: Users
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: users_field_data
|
||||
base_field: uid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: none
|
||||
cache:
|
||||
type: tag
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Filter
|
||||
reset_button: false
|
||||
reset_button_label: Reset
|
||||
exposed_sorts_label: 'Sort by'
|
||||
expose_sort_order: true
|
||||
sort_asc_label: Asc
|
||||
sort_desc_label: Desc
|
||||
pager:
|
||||
type: none
|
||||
options:
|
||||
offset: 0
|
||||
style:
|
||||
type: default
|
||||
options:
|
||||
row_class: ''
|
||||
default_row_class: true
|
||||
uses_fields: false
|
||||
row:
|
||||
type: fields
|
||||
options:
|
||||
separator: ''
|
||||
hide_empty: false
|
||||
default_field_elements: true
|
||||
fields:
|
||||
uid:
|
||||
id: uid
|
||||
table: users
|
||||
field: uid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
filters:
|
||||
uid_current:
|
||||
id: uid_current
|
||||
table: users
|
||||
field: uid_current
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '1'
|
||||
group: 1
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
entity_type: user
|
||||
plugin_id: user_current
|
||||
sorts: { }
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- user
|
||||
tags: { }
|
||||
|
|
@ -109,10 +109,12 @@ class MigrateUserTest extends MigrateDrupal7TestBase {
|
|||
* Role IDs the user account is expected to have.
|
||||
* @param int $field_integer
|
||||
* The value of the integer field.
|
||||
* @param int|false $field_file_target_id
|
||||
* (optional) The target ID of the file field.
|
||||
* @param bool $has_picture
|
||||
* Whether the user is expected to have a picture attached.
|
||||
* (optional) Whether the user is expected to have a picture attached.
|
||||
*/
|
||||
protected function assertEntity($id, $label, $mail, $password, $created, $access, $login, $blocked, $langcode, $timezone, $init, $roles, $field_integer, $has_picture = FALSE) {
|
||||
protected function assertEntity($id, $label, $mail, $password, $created, $access, $login, $blocked, $langcode, $timezone, $init, $roles, $field_integer, $field_file_target_id = FALSE, $has_picture = FALSE) {
|
||||
/** @var \Drupal\user\UserInterface $user */
|
||||
$user = User::load($id);
|
||||
$this->assertTrue($user instanceof UserInterface);
|
||||
|
|
@ -155,6 +157,10 @@ class MigrateUserTest extends MigrateDrupal7TestBase {
|
|||
$this->assertTrue($user->hasField('field_integer'));
|
||||
$this->assertEquals($field_integer[0], $user->field_integer->value);
|
||||
}
|
||||
if (!empty($field_file_target_id)) {
|
||||
$this->assertTrue($user->hasField('field_file'));
|
||||
$this->assertSame($field_file_target_id, $user->field_file->target_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -190,6 +196,13 @@ class MigrateUserTest extends MigrateDrupal7TestBase {
|
|||
->fetchCol();
|
||||
$field_integer = !empty($field_integer) ? $field_integer : NULL;
|
||||
|
||||
$field_file = Database::getConnection('default', 'migrate')
|
||||
->select('field_data_field_file', 'ff')
|
||||
->fields('ff', ['field_file_fid'])
|
||||
->condition('ff.entity_id', $source->uid)
|
||||
->execute()
|
||||
->fetchField();
|
||||
|
||||
$this->assertEntity(
|
||||
$source->uid,
|
||||
$source->name,
|
||||
|
|
@ -203,7 +216,8 @@ class MigrateUserTest extends MigrateDrupal7TestBase {
|
|||
$source->timezone,
|
||||
$source->init,
|
||||
$roles,
|
||||
$field_integer
|
||||
$field_integer,
|
||||
$field_file
|
||||
);
|
||||
|
||||
// Ensure that the user can authenticate.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\user\Kernel\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
use Drupal\Core\Session\AnonymousUserSession;
|
||||
|
||||
/**
|
||||
* Tests the current user filter handler.
|
||||
*
|
||||
* @group user
|
||||
* @see \Drupal\user\Plugin\views\filter\Current
|
||||
*/
|
||||
class HandlerFilterCurrentUserTest extends UserKernelTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_filter_current_user'];
|
||||
|
||||
/**
|
||||
* The current user.
|
||||
*
|
||||
* @var \Drupal\Core\Session\AccountProxy
|
||||
*/
|
||||
protected $currentUser;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
$this->currentUser = $this->container->get('current_user');
|
||||
$this->setupPermissionTestData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the current user filter handler with anonymous user.
|
||||
*/
|
||||
public function testFilterCurrentUserAsAnonymous() {
|
||||
$column_map = ['uid' => 'uid'];
|
||||
$this->currentUser->setAccount(new AnonymousUserSession());
|
||||
|
||||
$view = Views::getView('test_filter_current_user');
|
||||
$view->initHandlers();
|
||||
$view->filter['uid_current']->value = 0;
|
||||
$this->executeView($view);
|
||||
$expected[] = ['uid' => 1];
|
||||
$expected[] = ['uid' => 2];
|
||||
$expected[] = ['uid' => 3];
|
||||
$expected[] = ['uid' => 4];
|
||||
$this->assertIdenticalResultset($view, $expected, $column_map, 'Anonymous account can view all accounts when current filter is FALSE.');
|
||||
$view->destroy();
|
||||
|
||||
$view = Views::getView('test_filter_current_user');
|
||||
$view->initHandlers();
|
||||
$view->filter['uid_current']->value = 1;
|
||||
$this->executeView($view);
|
||||
$expected = [];
|
||||
$this->assertIdenticalResultset($view, $expected, $column_map, 'Anonymous account can view zero accounts when current filter is TRUE.');
|
||||
$view->destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the current user filter handler with logged-in user.
|
||||
*/
|
||||
public function testFilterCurrentUserAsUser() {
|
||||
$column_map = ['uid' => 'uid'];
|
||||
$user = reset($this->users);
|
||||
$this->currentUser->setAccount($user);
|
||||
|
||||
$view = Views::getView('test_filter_current_user');
|
||||
$view->initHandlers();
|
||||
$view->filter['uid_current']->value = 0;
|
||||
$this->executeView($view);
|
||||
$expected = [];
|
||||
$expected[] = ['uid' => 2];
|
||||
$expected[] = ['uid' => 3];
|
||||
$expected[] = ['uid' => 4];
|
||||
$this->assertIdenticalResultset($view, $expected, $column_map, 'User can view all users except itself when current filter is FALSE.');
|
||||
$view->destroy();
|
||||
|
||||
$view = Views::getView('test_filter_current_user');
|
||||
$view->initHandlers();
|
||||
$view->filter['uid_current']->value = 1;
|
||||
$this->executeView($view);
|
||||
$expected = [];
|
||||
$expected[] = ['uid' => 1];
|
||||
$this->assertIdenticalResultset($view, $expected, $column_map, 'User can only view itself when current filter is TRUE.');
|
||||
$view->destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -109,13 +109,16 @@ function hook_user_cancel_methods_alter(&$methods) {
|
|||
* that is displayed. Can be used to ensure user privacy in situations where
|
||||
* $account->getDisplayName() is too revealing.
|
||||
*
|
||||
* @param string $name
|
||||
* The string that $account->getDisplayName() will return.
|
||||
*
|
||||
* @param $account
|
||||
* The account object the name belongs to.
|
||||
* @param string|Drupal\Component\Render\MarkupInterface $name
|
||||
* The username that is displayed for a user. If a hook implementation changes
|
||||
* this to an object implementing MarkupInterface it is the responsibility of
|
||||
* the implementation to ensure the user's name is escaped properly. String
|
||||
* values will be autoescaped.
|
||||
* @param \Drupal\Core\Session\AccountInterface $account
|
||||
* The user object on which the operation is being performed.
|
||||
*
|
||||
* @see \Drupal\Core\Session\AccountInterface::getDisplayName()
|
||||
* @see sanitization
|
||||
*/
|
||||
function hook_user_format_name_alter(&$name, $account) {
|
||||
// Display the user's uid instead of name.
|
||||
|
|
|
|||
Reference in a new issue