Update to Drupal 8.0.5. For more information, see https://www.drupal.org/node/2679347
This commit is contained in:
parent
2a9f1f148d
commit
fd3b12cf27
251 changed files with 5439 additions and 957 deletions
|
@ -73,26 +73,6 @@ views.argument_default.node:
|
|||
type: string
|
||||
label: 'Nid'
|
||||
|
||||
views.argument_validator.node:
|
||||
type: mapping
|
||||
label: 'Content'
|
||||
mapping:
|
||||
types:
|
||||
type: sequence
|
||||
label: 'Content types'
|
||||
sequence:
|
||||
type: string
|
||||
label: 'Type'
|
||||
access:
|
||||
type: boolean
|
||||
label: 'Validate user has access to the content'
|
||||
access_op:
|
||||
type: boolean
|
||||
label: 'Access operation to check'
|
||||
nid_type:
|
||||
type: string
|
||||
label: 'Filter value format'
|
||||
|
||||
views.field.node:
|
||||
type: views_field
|
||||
label: 'Node'
|
||||
|
|
|
@ -148,10 +148,9 @@ function hook_node_grants(\Drupal\Core\Session\AccountInterface $account, $op) {
|
|||
* @param \Drupal\node\NodeInterface $node
|
||||
* The node that has just been saved.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array of grants as defined above.
|
||||
*
|
||||
* @see node_access_write_grants()
|
||||
* @see hook_node_access_records_alter()
|
||||
* @ingroup node_access
|
||||
*/
|
||||
|
|
|
@ -1155,6 +1155,11 @@ function node_access_rebuild($batch_mode = FALSE) {
|
|||
// quickly.
|
||||
$entity_query = \Drupal::entityQuery('node');
|
||||
$entity_query->sort('nid', 'DESC');
|
||||
// Disable access checking since all nodes must be processed even if the
|
||||
// user does not have access. And unless the current user has the bypass
|
||||
// node access permission, no nodes are accessible since the grants have
|
||||
// just been deleted.
|
||||
$entity_query->accessCheck(false);
|
||||
$nids = $entity_query->execute();
|
||||
foreach ($nids as $nid) {
|
||||
$node_storage->resetCache(array($nid));
|
||||
|
@ -1204,6 +1209,11 @@ function _node_access_rebuild_batch_operation(&$context) {
|
|||
$nids = \Drupal::entityQuery('node')
|
||||
->condition('nid', $context['sandbox']['current_node'], '>')
|
||||
->sort('nid', 'ASC')
|
||||
// Disable access checking since all nodes must be processed even if the
|
||||
// user does not have access. And unless the current user has the bypass
|
||||
// node access permission, no nodes are accessible since the grants have
|
||||
// just been deleted.
|
||||
->accessCheck(false)
|
||||
->range(0, $limit)
|
||||
->execute();
|
||||
$node_storage->resetCache($nids);
|
||||
|
|
|
@ -54,9 +54,11 @@ class NodeViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
|
||||
$data['node_field_data']['promote']['help'] = t('A boolean indicating whether the node is visible on the front page.');
|
||||
$data['node_field_data']['promote']['filter']['label'] = t('Promoted to front page status');
|
||||
$data['node_field_data']['promote']['filter']['type'] = 'yes-no';
|
||||
|
||||
$data['node_field_data']['sticky']['help'] = t('A boolean indicating whether the node should sort to the top of content lists.');
|
||||
$data['node_field_data']['sticky']['filter']['label'] = t('Sticky status');
|
||||
$data['node_field_data']['sticky']['filter']['type'] = 'yes-no';
|
||||
$data['node_field_data']['sticky']['sort']['help'] = t('Whether or not the content is sticky. To list sticky content first, set this to descending.');
|
||||
|
@ -256,6 +258,10 @@ class NodeViewsData extends EntityViewsData {
|
|||
$data['node_field_revision']['status']['filter']['type'] = 'yes-no';
|
||||
$data['node_field_revision']['status']['filter']['use_equal'] = TRUE;
|
||||
|
||||
$data['node_field_revision']['promote']['help'] = t('A boolean indicating whether the node is visible on the front page.');
|
||||
|
||||
$data['node_field_revision']['sticky']['help'] = t('A boolean indicating whether the node should sort to the top of content lists.');
|
||||
|
||||
$data['node_field_revision']['langcode']['help'] = t('The language of the content or translation.');
|
||||
|
||||
$data['node_field_revision']['link_to_revision'] = array(
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace Drupal\node\Tests\Migrate\d6;
|
|||
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrateIdMapInterface;
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
|
@ -24,9 +26,6 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigrations(['d6_node:*']);
|
||||
|
||||
// This is required for the second import below.
|
||||
\Drupal::database()->truncate(Migration::load('d6_node__story')->getIdMap()->mapTableName())->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,27 +52,61 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
// This is empty on the first revision.
|
||||
$this->assertIdentical(NULL, $node_revision->revision_log->value);
|
||||
|
||||
$node = Node::load(2);
|
||||
$this->assertIdentical('Test title rev 3', $node->getTitle());
|
||||
$this->assertIdentical('test rev 3', $node->body->value);
|
||||
$this->assertIdentical('filtered_html', $node->body->format);
|
||||
|
||||
// Test that we can re-import using the EntityContentBase destination.
|
||||
$connection = Database::getConnection('default', 'migrate');
|
||||
$connection->update('node_revisions')
|
||||
$title = $this->rerunMigration();
|
||||
$node = Node::load(2);
|
||||
$this->assertIdentical($title, $node->getTitle());
|
||||
// Test multi-column fields are correctly upgraded.
|
||||
$this->assertIdentical('test rev 3', $node->body->value);
|
||||
$this->assertIdentical('full_html', $node->body->format);
|
||||
|
||||
// Now insert a row indicating a failure and set to update later.
|
||||
$title = $this->rerunMigration(array(
|
||||
'sourceid1' => 2,
|
||||
'destid1' => NULL,
|
||||
'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
|
||||
));
|
||||
$node = Node::load(2);
|
||||
$this->assertIdentical($title, $node->getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the migration a second time.
|
||||
*
|
||||
* @param array $new_row
|
||||
* An optional row to be inserted into the id map.
|
||||
*
|
||||
* @return string
|
||||
* The new title in the source for vid 3.
|
||||
*/
|
||||
protected function rerunMigration($new_row = []) {
|
||||
$title = $this->randomString();
|
||||
$migration = Migration::load('d6_node__story');
|
||||
$source_connection = Database::getConnection('default', 'migrate');
|
||||
$source_connection->update('node_revisions')
|
||||
->fields(array(
|
||||
'title' => 'New node title',
|
||||
'title' => $title,
|
||||
'format' => 2,
|
||||
))
|
||||
->condition('vid', 1)
|
||||
->condition('vid', 3)
|
||||
->execute();
|
||||
$connection->delete('content_field_test_two')
|
||||
->condition('delta', 1)
|
||||
->execute();
|
||||
|
||||
$migration = Migration::load('d6_node__story');
|
||||
$table_name = $migration->getIdMap()->mapTableName();
|
||||
$default_connection = \Drupal::database();
|
||||
$default_connection->truncate($table_name)->execute();
|
||||
if ($new_row) {
|
||||
$hash = $migration->getIdMap()->getSourceIDsHash(['nid' => $new_row['sourceid1']]);
|
||||
$new_row['source_ids_hash'] = $hash;
|
||||
$default_connection->insert($table_name)
|
||||
->fields($new_row)
|
||||
->execute();
|
||||
}
|
||||
$this->executeMigration($migration);
|
||||
|
||||
$node = Node::load(1);
|
||||
$this->assertIdentical('New node title', $node->getTitle());
|
||||
// Test a multi-column fields are correctly upgraded.
|
||||
$this->assertIdentical('test', $node->body->value);
|
||||
$this->assertIdentical('full_html', $node->body->format);
|
||||
return $title;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -171,6 +171,22 @@ class NodeAccessBaseTableTest extends NodeTestBase {
|
|||
// This user should be able to see all of the nodes on the relevant
|
||||
// taxonomy pages.
|
||||
$this->assertTaxonomyPage(TRUE);
|
||||
|
||||
// Rebuild the node access permissions, repeat the test. This is done to
|
||||
// ensure that node access is rebuilt correctly even if the current user
|
||||
// does not have the bypass node access permission.
|
||||
node_access_rebuild();
|
||||
|
||||
foreach ($this->nodesByUser as $private_status) {
|
||||
foreach ($private_status as $nid => $is_private) {
|
||||
$this->drupalGet('node/' . $nid);
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
}
|
||||
|
||||
// This user should be able to see all of the nodes on the relevant
|
||||
// taxonomy pages.
|
||||
$this->assertTaxonomyPage(TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\node\Tests\Views\RevisionCreateTimestampTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\node\Tests\Views;
|
||||
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\views\Tests\ViewKernelTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Ensures that the revision create time can be accessed in views.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class RevisionCreateTimestampTest extends ViewKernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node_test_views', 'node', 'views', 'user'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $testViews = ['test_node_revision_timestamp'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->installSchema('node', 'node_access');
|
||||
$this->installEntitySchema('node');
|
||||
$this->installEntitySchema('user');
|
||||
|
||||
if ($import_test_views) {
|
||||
ViewTestData::createTestViews(get_class($this), ['node_test_views']);
|
||||
}
|
||||
}
|
||||
|
||||
public function testRevisionCreateTimestampView() {
|
||||
$node_type = NodeType::create([
|
||||
'type' => 'article',
|
||||
'label' => 'Article',
|
||||
]);
|
||||
$node_type->save();
|
||||
$node = Node::create([
|
||||
'title' => 'Test node',
|
||||
'type' => 'article',
|
||||
'revision_timestamp' => 1000,
|
||||
]);
|
||||
$node->save();
|
||||
|
||||
$node->setRevisionCreationTime(1200);
|
||||
$node->setNewRevision(TRUE);
|
||||
$node->save();
|
||||
|
||||
$node->setRevisionCreationTime(1400);
|
||||
$node->setNewRevision(TRUE);
|
||||
$node->save();
|
||||
|
||||
$view = Views::getView('test_node_revision_timestamp');
|
||||
$this->executeView($view);
|
||||
|
||||
$this->assertIdenticalResultset($view, [
|
||||
['vid' => 3, 'revision_timestamp' => 1400],
|
||||
['vid' => 2, 'revision_timestamp' => 1200],
|
||||
['vid' => 1, 'revision_timestamp' => 1000],
|
||||
], ['vid' => 'vid', 'revision_timestamp' => 'revision_timestamp']);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
id: test_node_revision_timestamp
|
||||
label: null
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_revision
|
||||
base_field: vid
|
||||
core: '8'
|
||||
display:
|
||||
default:
|
||||
display_options:
|
||||
fields:
|
||||
vid:
|
||||
id: vid
|
||||
table: node_field_revision
|
||||
field: vid
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: vid
|
||||
revision_timestamp:
|
||||
id: revision_timestamp
|
||||
table: node_revision
|
||||
field: revision_timestamp
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: revision_timestamp
|
||||
sorts:
|
||||
revision_timestamp:
|
||||
id: revision_timestamp
|
||||
table: node_revision
|
||||
field: revision_timestamp
|
||||
order: DESC
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: revision_timestamp
|
||||
display_plugin: default
|
||||
display_title: Master
|
||||
id: default
|
||||
position: 0
|
Reference in a new issue