composer update

This commit is contained in:
Oliver Davies 2019-01-24 08:00:03 +00:00
parent f6abc3dce2
commit 71dfaca858
1753 changed files with 45274 additions and 14619 deletions

View file

@ -338,19 +338,19 @@ function hook_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se
return AccessResult::allowedIfHasPermission($account, 'create ' . $type . ' content');
case 'update':
if ($account->hasPermission('edit any ' . $type . ' content', $account)) {
if ($account->hasPermission('edit any ' . $type . ' content')) {
return AccessResult::allowed()->cachePerPermissions();
}
else {
return AccessResult::allowedIf($account->hasPermission('edit own ' . $type . ' content', $account) && ($account->id() == $node->getOwnerId()))->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
return AccessResult::allowedIf($account->hasPermission('edit own ' . $type . ' content') && ($account->id() == $node->getOwnerId()))->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
}
case 'delete':
if ($account->hasPermission('delete any ' . $type . ' content', $account)) {
if ($account->hasPermission('delete any ' . $type . ' content')) {
return AccessResult::allowed()->cachePerPermissions();
}
else {
return AccessResult::allowedIf($account->hasPermission('delete own ' . $type . ' content', $account) && ($account->id() == $node->getOwnerId()))->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
return AccessResult::allowedIf($account->hasPermission('delete own ' . $type . ' content') && ($account->id() == $node->getOwnerId()))->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
}
default:

View file

@ -944,19 +944,19 @@ function node_node_access(NodeInterface $node, $op, $account) {
return AccessResult::allowedIfHasPermission($account, 'create ' . $type . ' content');
case 'update':
if ($account->hasPermission('edit any ' . $type . ' content', $account)) {
if ($account->hasPermission('edit any ' . $type . ' content')) {
return AccessResult::allowed()->cachePerPermissions();
}
else {
return AccessResult::allowedIf($account->hasPermission('edit own ' . $type . ' content', $account) && ($account->id() == $node->getOwnerId()))->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
return AccessResult::allowedIf($account->hasPermission('edit own ' . $type . ' content') && ($account->id() == $node->getOwnerId()))->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
}
case 'delete':
if ($account->hasPermission('delete any ' . $type . ' content', $account)) {
if ($account->hasPermission('delete any ' . $type . ' content')) {
return AccessResult::allowed()->cachePerPermissions();
}
else {
return AccessResult::allowedIf($account->hasPermission('delete own ' . $type . ' content', $account) && ($account->id() == $node->getOwnerId()))->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
return AccessResult::allowedIf($account->hasPermission('delete own ' . $type . ' content') && ($account->id() == $node->getOwnerId()))->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
}
default:

View file

@ -27,3 +27,10 @@ function node_post_update_configure_status_field_widget() {
])->save();
}
}
/**
* Clear caches due to updated views data.
*/
function node_post_update_node_revision_views_data() {
// Empty post-update hook.
}

View file

@ -216,6 +216,10 @@ class NodeViewsData extends EntityViewsData {
$data['node_field_revision']['nid']['relationship']['base field'] = 'nid';
$data['node_field_revision']['nid']['relationship']['title'] = $this->t('Content');
$data['node_field_revision']['nid']['relationship']['label'] = $this->t('Get the actual content from a content revision.');
$data['node_field_revision']['nid']['relationship']['extra'][] = [
'field' => 'langcode',
'left_field' => 'langcode',
];
$data['node_field_revision']['vid'] = [
'argument' => [
@ -228,6 +232,12 @@ class NodeViewsData extends EntityViewsData {
'base field' => 'vid',
'title' => $this->t('Content'),
'label' => $this->t('Get the actual content from a content revision.'),
'extra' => [
[
'field' => 'langcode',
'left_field' => 'langcode',
],
],
],
] + $data['node_field_revision']['vid'];

View file

@ -40,7 +40,7 @@ class NodeType extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
return [
$fields = [
'type' => $this->t('Machine name of the node type.'),
'name' => $this->t('Human name of the node type.'),
'description' => $this->t('Description of the node type.'),

View file

@ -52,7 +52,7 @@ use Drupal\node\NodeInterface;
function node_access_test_node_grants($account, $op) {
$grants = [];
$grants['node_access_test_author'] = [$account->id()];
if ($op == 'view' && $account->hasPermission('node test view', $account)) {
if ($op == 'view' && $account->hasPermission('node test view')) {
$grants['node_access_test'] = [8888, 8889];
}

View file

@ -44,6 +44,13 @@ display:
plugin_id: field
entity_type: node
entity_field: nid
langcode:
id: langcode
table: node_field_revision
field: langcode
plugin_id: field
entity_type: node
entity_field: langcode
arguments:
nid:
id: nid
@ -61,6 +68,21 @@ display:
plugin_id: field
entity_type: node
entity_field: vid
langcode:
id: langcode
table: node_field_revision
field: langcode
relationship: none
group_type: group
admin_label: ''
order: DESC
exposed: false
expose:
label: ''
entity_type: node
entity_field: langcode
plugin_id: standard
display_extenders: { }
display_plugin: default
display_title: Master
id: default

View file

@ -44,6 +44,13 @@ display:
plugin_id: field
entity_type: node
entity_field: nid
langcode:
id: langcode
table: node_field_revision
field: langcode
entity_type: node
entity_field: langcode
plugin_id: field
arguments:
nid:
id: nid
@ -52,6 +59,22 @@ display:
plugin_id: node_nid
entity_type: node
entity_field: nid
display_extenders: { }
sorts:
langcode:
id: langcode
table: node_field_revision
field: langcode
relationship: none
group_type: group
admin_label: ''
order: ASC
exposed: false
expose:
label: ''
entity_type: node
entity_field: langcode
plugin_id: standard
display_plugin: default
display_title: Master
id: default

View file

@ -153,7 +153,7 @@ class NodeRevisionPermissionsTest extends NodeTestBase {
foreach ($permutations as $case) {
// Skip this test if there are no revisions for the node.
if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', [':nid' => $revision->id()])->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
if (!empty($case['account']->is_admin) || $case['account']->hasPermission($this->typeMap[$case['op']], $case['account'])) {
if (!empty($case['account']->is_admin) || $case['account']->hasPermission($this->typeMap[$case['op']])) {
$this->assertTrue($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->typeMap[$case['op']]} granted.");
}
else {

View file

@ -2,6 +2,7 @@
namespace Drupal\Tests\node\Kernel\Views;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
@ -20,7 +21,12 @@ class RevisionRelationshipsTest extends ViewsKernelTestBase {
*
* @var array
*/
public static $modules = ['node' , 'node_test_views'];
public static $modules = [
'node',
'node_test_views',
'language',
'content_translation',
];
/**
* {@inheritdoc}
@ -33,6 +39,8 @@ class RevisionRelationshipsTest extends ViewsKernelTestBase {
$this->installEntitySchema('user');
$this->installEntitySchema('node');
ConfigurableLanguage::createFromLangcode('fr')->save();
ViewTestData::createTestViews(get_class($this), ['node_test_views']);
}
@ -51,16 +59,22 @@ class RevisionRelationshipsTest extends ViewsKernelTestBase {
$type->save();
$node = Node::create(['type' => 'page', 'title' => 'test', 'uid' => 1]);
$node->save();
// Add a translation.
$translation = $node->addTranslation('fr', $node->toArray());
$translation->save();
// Create revision of the node.
$node->setNewRevision(TRUE);
$node->save();
$column_map = [
'vid' => 'vid',
'node_field_data_node_field_revision_nid' => 'node_node_revision_nid',
'nid_1' => 'nid_1',
'node_field_revision_langcode' => 'node_field_revision_langcode',
];
// Here should be two rows.
// Here should be two rows for each translation.
$view_nid = Views::getView('test_node_revision_nid');
$this->executeView($view_nid, [$node->id()]);
$resultset_nid = [
@ -68,17 +82,32 @@ class RevisionRelationshipsTest extends ViewsKernelTestBase {
'vid' => '1',
'node_node_revision_nid' => '1',
'nid_1' => '1',
'node_field_revision_langcode' => 'fr',
],
[
'vid' => '1',
'node_node_revision_nid' => '1',
'nid_1' => '1',
'node_field_revision_langcode' => 'en',
],
[
'vid' => '2',
'node_revision_nid' => '1',
'node_node_revision_nid' => '1',
'nid_1' => '1',
'node_field_revision_langcode' => 'fr',
],
[
'vid' => '2',
'node_revision_nid' => '1',
'node_node_revision_nid' => '1',
'nid_1' => '1',
'node_field_revision_langcode' => 'en',
],
];
$this->assertIdenticalResultset($view_nid, $resultset_nid, $column_map);
// There should be only one row with active revision 2.
// There should be one row with active revision 2 for each translation.
$view_vid = Views::getView('test_node_revision_vid');
$this->executeView($view_vid, [$node->id()]);
$resultset_vid = [
@ -86,6 +115,13 @@ class RevisionRelationshipsTest extends ViewsKernelTestBase {
'vid' => '2',
'node_node_revision_nid' => '1',
'nid_1' => '1',
'node_field_revision_langcode' => 'en',
],
[
'vid' => '2',
'node_node_revision_nid' => '1',
'nid_1' => '1',
'node_field_revision_langcode' => 'fr',
],
];
$this->assertIdenticalResultset($view_vid, $resultset_vid, $column_map);