Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
15
core/modules/tracker/migration_templates/d7_tracker_node.yml
Normal file
15
core/modules/tracker/migration_templates/d7_tracker_node.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
id: d7_tracker_node
|
||||
label: Tracker node
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: d7_tracker_node
|
||||
process:
|
||||
nid: nid
|
||||
published: published
|
||||
changed: changed
|
||||
destination:
|
||||
plugin: entity:node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_user
|
|
@ -1,5 +1,5 @@
|
|||
id: d7_tracker_settings
|
||||
label: Drupal 7 tracker settings
|
||||
label: Tracker settings
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
|
|
16
core/modules/tracker/migration_templates/d7_tracker_user.yml
Normal file
16
core/modules/tracker/migration_templates/d7_tracker_user.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
id: d7_tracker_user
|
||||
label: Tracker user
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: d7_tracker_user
|
||||
process:
|
||||
nid: nid
|
||||
uid: uid
|
||||
published: published
|
||||
changed: changed
|
||||
destination:
|
||||
plugin: entity:user
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_user
|
|
@ -9,7 +9,6 @@ namespace Drupal\tracker\Controller;
|
|||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\user\UserInterface;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
|
||||
/**
|
||||
* Controller for tracker.user_tab route.
|
||||
|
@ -28,6 +27,6 @@ class TrackerUserTab extends ControllerBase {
|
|||
* Title callback for the tracker.user_tab route.
|
||||
*/
|
||||
public function getTitle(UserInterface $user) {
|
||||
return SafeMarkup::checkPlain($user->getUsername());
|
||||
return $user->getUsername();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\tracker\Plugin\migrate\source\d7\TrackerNode.
|
||||
*/
|
||||
|
||||
namespace Drupal\tracker\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 7 tracker node source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_tracker_node",
|
||||
* source_provider = "tracker"
|
||||
* )
|
||||
*/
|
||||
class TrackerNode extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('tracker_node', 'tn')->fields('tn');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'nid' => $this->t('The {node}.nid this record tracks.'),
|
||||
'published' => $this->t('Boolean indicating whether the node is published.'),
|
||||
'changed' => $this->t('The Unix timestamp when the node was most recently saved or commented on.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['nid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\tracker\Plugin\migrate\source\d7\TrackerUser.
|
||||
*/
|
||||
|
||||
namespace Drupal\tracker\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 7 tracker user source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_tracker_user",
|
||||
* source_provider = "tracker"
|
||||
* )
|
||||
*/
|
||||
class TrackerUser extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('tracker_user', 'tu')->fields('tu');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'nid' => $this->t('The {user}.nid this record tracks.'),
|
||||
'uid' => $this->t('The {users}.uid of the node author or commenter.'),
|
||||
'published' => $this->t('Boolean indicating whether the node is published.'),
|
||||
'changed' => $this->t('The Unix timestamp when the user was most recently saved or commented on.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['nid']['type'] = 'integer';
|
||||
$ids['uid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\tracker\Tests\Migrate\d7\MigrateTrackerNodeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\tracker\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
/**
|
||||
* Tests migration of tracker_node.
|
||||
*
|
||||
* @group tracker
|
||||
*/
|
||||
class MigrateTrackerNodeTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'node',
|
||||
'text',
|
||||
'tracker',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('node');
|
||||
$this->installConfig(static::$modules);
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->installSchema('tracker', ['tracker_node', 'tracker_user']);
|
||||
|
||||
$this->executeMigrations([
|
||||
'd7_user_role',
|
||||
'd7_user',
|
||||
'd7_node_type',
|
||||
'd7_node__test_content_type',
|
||||
'd7_tracker_node',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of tracker node table.
|
||||
*/
|
||||
public function testMigrateTrackerNode() {
|
||||
$connection = Database::getConnection('default', 'migrate');
|
||||
$num_rows = $connection
|
||||
->select('tracker_node', 'tn')
|
||||
->fields('tn', ['nid', 'published', 'changed'])
|
||||
->countQuery()
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertIdentical('1', $num_rows);
|
||||
|
||||
$tracker_nodes = $connection
|
||||
->select('tracker_node', 'tn')
|
||||
->fields('tn', ['nid', 'published', 'changed'])
|
||||
->execute();
|
||||
$row = $tracker_nodes->fetchAssoc();
|
||||
$this->assertIdentical('1', $row['nid']);
|
||||
$this->assertIdentical('1', $row['published']);
|
||||
$this->assertIdentical('1421727536', $row['changed']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\tracker\Tests\Migrate\d7\MigrateTrackerUserTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\tracker\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
/**
|
||||
* Tests migration of tracker_user.
|
||||
*
|
||||
* @group tracker
|
||||
*/
|
||||
class MigrateTrackerUserTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'node',
|
||||
'text',
|
||||
'tracker',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('node');
|
||||
$this->installConfig(static::$modules);
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->installSchema('tracker', ['tracker_node', 'tracker_user']);
|
||||
|
||||
$this->executeMigrations([
|
||||
'd7_user_role',
|
||||
'd7_user',
|
||||
'd7_node_type',
|
||||
'd7_node__test_content_type',
|
||||
'd7_tracker_node',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of tracker user table.
|
||||
*/
|
||||
public function testMigrateTrackerUser() {
|
||||
$connection = Database::getConnection('default', 'migrate');
|
||||
$num_rows = $connection
|
||||
->select('tracker_user', 'tn')
|
||||
->fields('tu', ['nid', 'uid', 'published', 'changed'])
|
||||
->countQuery()
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertIdentical('1', $num_rows);
|
||||
|
||||
$tracker_nodes = $connection
|
||||
->select('tracker_user', 'tu')
|
||||
->fields('tu', ['nid', 'uid', 'published', 'changed'])
|
||||
->execute();
|
||||
$row = $tracker_nodes->fetchAssoc();
|
||||
$this->assertIdentical('1', $row['nid']);
|
||||
$this->assertIdentical('2', $row['uid']);
|
||||
$this->assertIdentical('1', $row['published']);
|
||||
$this->assertIdentical('1421727536', $row['changed']);
|
||||
}
|
||||
|
||||
}
|
|
@ -86,10 +86,16 @@ class TrackerTest extends WebTestBase {
|
|||
$this->assertLink(t('My recent content'), 0, 'User tab shows up on the global tracker page.');
|
||||
|
||||
// Assert cache contexts, specifically the pager and node access contexts.
|
||||
$this->assertCacheContexts(['languages:language_interface', 'route.name', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user.node_grants:view', 'user']);
|
||||
$this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user.node_grants:view', 'user']);
|
||||
// Assert cache tags for the action/tabs blocks, visible node, and node list
|
||||
// cache tag.
|
||||
$expected_tags = Cache::mergeTags($published->getCacheTags(), $published->getOwner()->getCacheTags());
|
||||
// Because the 'user.permissions' cache context is being optimized away.
|
||||
$role_tags = [];
|
||||
foreach ($this->user->getRoles() as $rid) {
|
||||
$role_tags[] = "config:user.role.$rid";
|
||||
}
|
||||
$expected_tags = Cache::mergeTags($expected_tags, $role_tags);
|
||||
$block_tags = [
|
||||
'block_view',
|
||||
'config:block.block.page_actions_block',
|
||||
|
@ -164,12 +170,18 @@ class TrackerTest extends WebTestBase {
|
|||
$this->assertText($other_published_my_comment->label(), "Nodes that the user has commented on appear in the user's tracker listing.");
|
||||
|
||||
// Assert cache contexts.
|
||||
$this->assertCacheContexts(['languages:language_interface', 'route.name', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user', 'user.node_grants:view']);
|
||||
$this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user', 'user.node_grants:view']);
|
||||
// Assert cache tags for the visible nodes (including owners) and node list
|
||||
// cache tag.
|
||||
$expected_tags = Cache::mergeTags($my_published->getCacheTags(), $my_published->getOwner()->getCacheTags());
|
||||
$expected_tags = Cache::mergeTags($expected_tags, $other_published_my_comment->getCacheTags());
|
||||
$expected_tags = Cache::mergeTags($expected_tags, $other_published_my_comment->getOwner()->getCacheTags());
|
||||
// Because the 'user.permissions' cache context is being optimized away.
|
||||
$role_tags = [];
|
||||
foreach ($this->user->getRoles() as $rid) {
|
||||
$role_tags[] = "config:user.role.$rid";
|
||||
}
|
||||
$expected_tags = Cache::mergeTags($expected_tags, $role_tags);
|
||||
$block_tags = [
|
||||
'block_view',
|
||||
'config:block.block.page_actions_block',
|
||||
|
@ -184,7 +196,7 @@ class TrackerTest extends WebTestBase {
|
|||
$expected_tags = Cache::mergeTags($expected_tags, $additional_tags);
|
||||
|
||||
$this->assertCacheTags($expected_tags);
|
||||
$this->assertCacheContexts(['languages:language_interface', 'route.name', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user', 'user.node_grants:view']);
|
||||
$this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user', 'user.node_grants:view']);
|
||||
|
||||
$this->assertLink($my_published->label());
|
||||
$this->assertNoLink($unpublished->label());
|
||||
|
@ -198,6 +210,19 @@ class TrackerTest extends WebTestBase {
|
|||
$this->drupalPostForm('comment/1/edit', array('status' => CommentInterface::NOT_PUBLISHED), t('Save'));
|
||||
$this->drupalGet('user/' . $this->user->id() . '/activity');
|
||||
$this->assertNoText($other_published_my_comment->label(), 'Unpublished comments are not counted on the tracker listing.');
|
||||
|
||||
// Test escaping of title on user's tracker tab.
|
||||
\Drupal::service('module_installer')->install(['user_hooks_test']);
|
||||
Cache::invalidateTags(['rendered']);
|
||||
\Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
|
||||
$this->drupalGet('user/' . $this->user->id() . '/activity');
|
||||
$this->assertEscaped('<em>' . $this->user->id() . '</em>');
|
||||
|
||||
\Drupal::state()->set('user_hooks_test_user_format_name_alter_safe', TRUE);
|
||||
Cache::invalidateTags(['rendered']);
|
||||
$this->drupalGet('user/' . $this->user->id() . '/activity');
|
||||
$this->assertNoEscaped('<em>' . $this->user->id() . '</em>');
|
||||
$this->assertRaw('<em>' . $this->user->id() . '</em>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\tracker\Unit\Plugin\migrate\source\d7\TrackerNodeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\tracker\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 tracker node source plugin.
|
||||
*
|
||||
* @group tracker
|
||||
*/
|
||||
class TrackerNodeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\tracker\Plugin\migrate\source\d7\TrackerNode';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd7_tracker_node',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'nid' => '2',
|
||||
'published' => '1',
|
||||
'changed' => '1421727536',
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['tracker_node'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\tracker\Unit\Plugin\migrate\source\d7\TrackerUserTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\tracker\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 tracker user source plugin.
|
||||
*
|
||||
* @group tracker
|
||||
*/
|
||||
class TrackerUserTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\tracker\Plugin\migrate\source\d7\TrackerUser';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd7_tracker_user',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'nid' => '1',
|
||||
'uid' => '2',
|
||||
'published' => '1',
|
||||
'changed' => '1421727536',
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['tracker_user'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -19,11 +19,11 @@ function tracker_help($route_name, RouteMatchInterface $route_match) {
|
|||
switch ($route_name) {
|
||||
case 'help.page.tracker':
|
||||
$output = '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Activity Tracker module displays the most recently added and updated content on your site, and allows you to follow new content created by each user. This module has no configuration options. For more information, see the <a href="!tracker">online documentation for the Tracker module</a>.', array('!tracker' => 'https://www.drupal.org/documentation/modules/tracker')) . '</p>';
|
||||
$output .= '<p>' . t('The Activity Tracker module displays the most recently added and updated content on your site, and allows you to follow new content created by each user. This module has no configuration options. For more information, see the <a href=":tracker">online documentation for the Activity Tracker module</a>.', array(':tracker' => 'https://www.drupal.org/documentation/modules/tracker')) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Tracking new and updated site content') . '</dt>';
|
||||
$output .= '<dd>' . t('The <a href="!recent">Recent content</a> page shows new and updated content in reverse chronological order, listing the content type, title, author\'s name, number of comments, and time of last update. Content is considered updated when changes occur in the text, or when new comments are added. The <em>My recent content</em> tab limits the list to the currently logged-in user.', array('!recent' => \Drupal::url('tracker.page'))) . '</dd>';
|
||||
$output .= '<dd>' . t('The <a href=":recent">Recent content</a> page shows new and updated content in reverse chronological order, listing the content type, title, author\'s name, number of comments, and time of last update. Content is considered updated when changes occur in the text, or when new comments are added. The <em>My recent content</em> tab limits the list to the currently logged-in user.', array(':recent' => \Drupal::url('tracker.page'))) . '</dd>';
|
||||
$output .= '<dt>' . t('Tracking user-specific content') . '</dt>';
|
||||
$output .= '<dd>' . t("To follow a specific user's new and updated content, select the <em>Activity</em> tab from the user's profile page.") . '</dd>';
|
||||
$output .= '</dl>';
|
||||
|
|
|
@ -106,8 +106,8 @@ function tracker_page($account = NULL) {
|
|||
'data-history-node-last-comment-timestamp' => $node->last_comment_timestamp,
|
||||
),
|
||||
'last updated' => array(
|
||||
'data' => t('!time ago', array(
|
||||
'!time' => \Drupal::service('date.formatter')->formatTimeDiffSince($node->last_activity),
|
||||
'data' => t('@time ago', array(
|
||||
'@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($node->last_activity),
|
||||
)),
|
||||
),
|
||||
);
|
||||
|
|
Reference in a new issue