Update to Drupal 8.2.4. For more information, see https://www.drupal.org/project/drupal/releases/8.2.4
This commit is contained in:
parent
0a95b8440e
commit
8544b60b39
284 changed files with 12980 additions and 3199 deletions
|
|
@ -9,6 +9,8 @@ process:
|
|||
# In D6, nodes always have a tnid, but it's zero for untranslated nodes.
|
||||
# We normalize it to equal the nid in that case.
|
||||
# @see \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow().
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the nid and vid fields to allow incremental migrations.
|
||||
nid: tnid
|
||||
vid: vid
|
||||
langcode:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ deriver: Drupal\node\Plugin\migrate\D6NodeDeriver
|
|||
source:
|
||||
plugin: d6_node_revision
|
||||
process:
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the nid and vid fields to allow incremental migrations.
|
||||
nid: nid
|
||||
vid: vid
|
||||
langcode:
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ source:
|
|||
plugin: d6_node
|
||||
translations: true
|
||||
process:
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the nid field to allow incremental migrations.
|
||||
nid: tnid
|
||||
type: type
|
||||
langcode:
|
||||
|
|
@ -29,6 +31,7 @@ process:
|
|||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
content_translation_source: source_langcode
|
||||
|
||||
# unmapped d6 fields.
|
||||
# translate
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
|
|||
source:
|
||||
plugin: d7_node
|
||||
process:
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the nid and vid fields to allow incremental migrations.
|
||||
nid: nid
|
||||
vid: vid
|
||||
langcode:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
|
|||
source:
|
||||
plugin: d7_node_revision
|
||||
process:
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the nid and vid fields to allow incremental migrations.
|
||||
nid: nid
|
||||
vid: vid
|
||||
langcode:
|
||||
|
|
|
|||
|
|
@ -3,8 +3,13 @@
|
|||
namespace Drupal\node\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Core\Database\Query\SelectInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Extension\ModuleHandler;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Drupal 6 node source from database.
|
||||
|
|
@ -34,6 +39,36 @@ class Node extends DrupalSqlBase {
|
|||
*/
|
||||
protected $fieldInfo;
|
||||
|
||||
/**
|
||||
* The module handler.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandler
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, ModuleHandler $module_handler) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('state'),
|
||||
$container->get('entity.manager'),
|
||||
$container->get('module_handler')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -68,6 +103,13 @@ class Node extends DrupalSqlBase {
|
|||
$query->addField('n', 'uid', 'node_uid');
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
|
||||
// If the content_translation module is enabled, get the source langcode
|
||||
// to fill the content_translation_source field.
|
||||
if ($this->moduleHandler->moduleExists('content_translation')) {
|
||||
$query->leftJoin('node', 'nt', 'n.tnid = nt.nid');
|
||||
$query->addField('nt', 'language', 'source_langcode');
|
||||
}
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('n.type', $this->configuration['node_type']);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Access extends FilterPluginBase {
|
|||
*/
|
||||
public function query() {
|
||||
$account = $this->view->getUser();
|
||||
if (!$account->hasPermission('administer nodes')) {
|
||||
if (!$account->hasPermission('bypass node access')) {
|
||||
$table = $this->ensureMyTable();
|
||||
$grants = db_or();
|
||||
foreach (node_access_grants('view', $account) as $realm => $gids) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Drupal\node\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
|
||||
/**
|
||||
* Tests the node/{node} page.
|
||||
*
|
||||
|
|
@ -63,6 +65,24 @@ class NodeViewTest extends NodeTestBase {
|
|||
$this->assertEqual($result[0]['href'], $node->url('edit-form'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Link header.
|
||||
*/
|
||||
public function testLinkHeader() {
|
||||
$node = $this->drupalCreateNode();
|
||||
|
||||
$expected = [
|
||||
'<' . Html::escape($node->url('canonical')) . '>; rel="canonical"',
|
||||
'<' . Html::escape($node->url('canonical'), ['alias' => TRUE]) . '>; rel="shortlink"',
|
||||
'<' . Html::escape($node->url('revision')) . '>; rel="revision"',
|
||||
];
|
||||
|
||||
$this->drupalGet($node->urlInfo());
|
||||
|
||||
$links = explode(',', $this->drupalGetHeader('Link'));
|
||||
$this->assertEqual($links, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that we store and retrieve multi-byte UTF-8 characters correctly.
|
||||
*/
|
||||
|
|
|
|||
111
core/modules/node/src/Tests/Views/FilterNodeAccessTest.php
Normal file
111
core/modules/node/src/Tests/Views/FilterNodeAccessTest.php
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\node\Tests\Views;
|
||||
|
||||
use Drupal\node\Entity\NodeType;
|
||||
|
||||
/**
|
||||
* Tests the node_access filter handler.
|
||||
*
|
||||
* @group node
|
||||
* @see \Drupal\node\Plugin\views\filter\Access
|
||||
*/
|
||||
class FilterNodeAccessTest extends NodeTestBase {
|
||||
|
||||
/**
|
||||
* An array of users.
|
||||
*
|
||||
* @var \Drupal\user\Entity\User[]
|
||||
*/
|
||||
protected $users;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node_access_test'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_filter_node_access'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
|
||||
|
||||
node_access_test_add_field(NodeType::load('article'));
|
||||
|
||||
node_access_rebuild();
|
||||
\Drupal::state()->set('node_access_test.private', TRUE);
|
||||
|
||||
$num_simple_users = 2;
|
||||
$this->users = [];
|
||||
|
||||
for ($i = 0; $i < $num_simple_users; $i++) {
|
||||
$this->users[$i] = $this->drupalCreateUser(['access content', 'create article content']);
|
||||
}
|
||||
foreach ($this->users as $web_user) {
|
||||
$this->drupalLogin($web_user);
|
||||
foreach ([0 => 'Public', 1 => 'Private'] as $is_private => $type) {
|
||||
$settings = [
|
||||
'body' => [[
|
||||
'value' => $type . ' node',
|
||||
'format' => filter_default_format(),
|
||||
]],
|
||||
'title' => t('@private_public Article created by @user', ['@private_public' => $type, '@user' => $web_user->getUsername()]),
|
||||
'type' => 'article',
|
||||
'uid' => $web_user->id(),
|
||||
'private' => (bool) $is_private,
|
||||
];
|
||||
|
||||
$node = $this->drupalCreateNode($settings);
|
||||
$this->assertEqual($is_private, (int) $node->private->value, 'The private status of the node was properly set in the node_access_test table.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the node access filter.
|
||||
*/
|
||||
public function testFilterNodeAccess() {
|
||||
$this->drupalLogin($this->users[0]);
|
||||
$this->drupalGet('test_filter_node_access');
|
||||
// Test that the private node of the current user is shown.
|
||||
$this->assertText('Private Article created by ' . $this->users[0]->getUsername());
|
||||
// Test that the private node of the other use isn't shown.
|
||||
$this->assertNoText('Private Article created by ' . $this->users[1]->getUsername());
|
||||
// Test that both public nodes are shown.
|
||||
$this->assertText('Public Article created by ' . $this->users[0]->getUsername());
|
||||
$this->assertText('Public Article created by ' . $this->users[1]->getUsername());
|
||||
|
||||
// Switch users and test the other private node is shown.
|
||||
$this->drupalLogin($this->users[1]);
|
||||
$this->drupalGet('test_filter_node_access');
|
||||
// Test that the private node of the current user is shown.
|
||||
$this->assertText('Private Article created by ' . $this->users[1]->getUsername());
|
||||
// Test that the private node of the other use isn't shown.
|
||||
$this->assertNoText('Private Article created by ' . $this->users[0]->getUsername());
|
||||
|
||||
// Test that a user with administer nodes permission can't see all nodes.
|
||||
$administer_nodes_user = $this->drupalCreateUser(['access content', 'administer nodes']);
|
||||
$this->drupalLogin($administer_nodes_user);
|
||||
$this->drupalGet('test_filter_node_access');
|
||||
$this->assertNoText('Private Article created by ' . $this->users[0]->getUsername());
|
||||
$this->assertNoText('Private Article created by ' . $this->users[1]->getUsername());
|
||||
$this->assertText('Public Article created by ' . $this->users[0]->getUsername());
|
||||
$this->assertText('Public Article created by ' . $this->users[1]->getUsername());
|
||||
|
||||
// Test that a user with bypass node access can see all nodes.
|
||||
$bypass_access_user = $this->drupalCreateUser(['access content', 'bypass node access']);
|
||||
$this->drupalLogin($bypass_access_user);
|
||||
$this->drupalGet('test_filter_node_access');
|
||||
$this->assertText('Private Article created by ' . $this->users[0]->getUsername());
|
||||
$this->assertText('Private Article created by ' . $this->users[1]->getUsername());
|
||||
$this->assertText('Public Article created by ' . $this->users[0]->getUsername());
|
||||
$this->assertText('Public Article created by ' . $this->users[1]->getUsername());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
- user
|
||||
id: test_filter_node_access
|
||||
label: test_filter_node_access
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: nid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
options:
|
||||
perm: 'access content'
|
||||
cache:
|
||||
type: tag
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: true
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
query_tags: { }
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Apply
|
||||
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: some
|
||||
options:
|
||||
items_per_page: 10
|
||||
offset: 0
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
options:
|
||||
default_field_elements: true
|
||||
inline: { }
|
||||
separator: ''
|
||||
hide_empty: false
|
||||
fields:
|
||||
title:
|
||||
id: title
|
||||
table: node_field_data
|
||||
field: title
|
||||
entity_type: node
|
||||
entity_field: title
|
||||
label: ''
|
||||
alter:
|
||||
alter_text: false
|
||||
make_link: false
|
||||
absolute: false
|
||||
trim: false
|
||||
word_boundary: false
|
||||
ellipsis: false
|
||||
strip_tags: false
|
||||
html: false
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
settings:
|
||||
link_to_entity: true
|
||||
plugin_id: field
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
exclude: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: string
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
filters:
|
||||
status:
|
||||
value: '1'
|
||||
table: node_field_data
|
||||
field: status
|
||||
plugin_id: boolean
|
||||
entity_type: node
|
||||
entity_field: status
|
||||
id: status
|
||||
expose:
|
||||
operator: ''
|
||||
group: 1
|
||||
nid:
|
||||
id: nid
|
||||
table: node_access
|
||||
field: nid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: ''
|
||||
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: { }
|
||||
plugin_id: node_access
|
||||
sorts:
|
||||
created:
|
||||
id: created
|
||||
table: node_field_data
|
||||
field: created
|
||||
order: DESC
|
||||
entity_type: node
|
||||
entity_field: created
|
||||
plugin_id: date
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
exposed: false
|
||||
expose:
|
||||
label: ''
|
||||
granularity: second
|
||||
title: test_filter_node_access
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
tags: { }
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: test_filter_node_access
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
tags: { }
|
||||
|
|
@ -28,7 +28,12 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
parent::setUp();
|
||||
$this->setUpMigratedFiles();
|
||||
$this->installSchema('file', ['file_usage']);
|
||||
$this->executeMigrations(['language', 'd6_node', 'd6_node_translation']);
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_language_content_settings',
|
||||
'd6_node',
|
||||
'd6_node_translation',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,6 +101,14 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
$this->assertIdentical('The Real McCoy', $node->title->value);
|
||||
$this->assertTrue($node->hasTranslation('fr'), "Node 10 has french translation");
|
||||
|
||||
// Test that content_translation_source is set.
|
||||
$manager = $this->container->get('content_translation.manager');
|
||||
$this->assertIdentical('en', $manager->getTranslationMetadata($node->getTranslation('fr'))->getSource());
|
||||
|
||||
// Test that content_translation_source for a source other than English.
|
||||
$node = Node::load(12);
|
||||
$this->assertIdentical('zu', $manager->getTranslationMetadata($node->getTranslation('en'))->getSource());
|
||||
|
||||
// Node 11 is a translation of node 10, and should not be imported separately.
|
||||
$this->assertNull(Node::load(11), "Node 11 doesn't exist in D8, it was a translation");
|
||||
|
||||
|
|
|
|||
Reference in a new issue