Update to Drupal 8.0.2. For more information, see https://www.drupal.org/drupal-8.0.2-release-notes

This commit is contained in:
Pantheon Automation 2016-01-06 16:31:26 -08:00 committed by Greg Anderson
parent 1a0e9d9fac
commit a6b049dd05
538 changed files with 5247 additions and 1594 deletions

View file

@ -1,48 +0,0 @@
id: d6_menu_links
label: Menu links
migration_tags:
- Drupal 6
source:
plugin: menu_link
constants:
bundle: menu_link_content
process:
id: mlid
bundle: 'constants/bundle'
title: link_title
description:
plugin: extract
source:
- options
index:
- 0
- attributes
- title
default: ''
menu_name:
plugin: migration
migration: menu
source: menu_name
'link/uri':
plugin: internal_uri
source:
- link_path
'link/options': options
external: external
weight: weight
expanded: expanded
enabled: enabled
parent:
-
plugin: skip_on_empty
method: process
source: plid
-
plugin: migration
migration: d6_menu_links
changed: updated
destination:
plugin: entity:menu_link_content
migration_dependencies:
required:
- menu

View file

@ -1,6 +1,7 @@
id: d7_menu_links
id: menu_links
label: Menu links
migration_tags:
- Drupal 6
- Drupal 7
source:
plugin: menu_link
@ -10,19 +11,17 @@ process:
id: mlid
bundle: 'constants/bundle'
title: link_title
description:
plugin: extract
source:
- options
index:
- 0
- attributes
- title
default: ''
description: description
menu_name:
plugin: migration
migration: menu
source: menu_name
-
plugin: migration
migration: menu
source: menu_name
-
plugin: static_map
map:
management: admin
bypass: true
'link/uri':
plugin: internal_uri
source:
@ -42,16 +41,15 @@ process:
expanded: expanded
enabled: enabled
parent:
-
plugin: skip_on_empty
method: process
source: plid
-
plugin: migration
migration: d7_menu_links
plugin: menu_link_parent
source:
- plid
- @menu_name
- parent_link_path
changed: updated
destination:
plugin: entity:menu_link_content
no_stub: true
migration_dependencies:
required:
- menu

View file

@ -200,15 +200,22 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
// The menu link can just be updated if there is already an menu link entry
// on both entity and menu link plugin level.
if ($update && $menu_link_manager->getDefinition($this->getPluginId())) {
$definition = $this->getPluginDefinition();
// Even when $update is FALSE, for top level links it is possible the link
// already is in the storage because of the getPluginDefinition() call
// above, see https://www.drupal.org/node/2605684#comment-10515450 for the
// call chain. Because of this the $update flag is ignored and only the
// existence of the definition (equals to being in the tree storage) is
// checked.
if ($menu_link_manager->getDefinition($this->getPluginId(), FALSE)) {
// When the entity is saved via a plugin instance, we should not call
// the menu tree manager to update the definition a second time.
if (!$this->insidePlugin) {
$menu_link_manager->updateDefinition($this->getPluginId(), $this->getPluginDefinition(), FALSE);
$menu_link_manager->updateDefinition($this->getPluginId(), $definition, FALSE);
}
}
else {
$menu_link_manager->addDefinition($this->getPluginId(), $this->getPluginDefinition());
$menu_link_manager->addDefinition($this->getPluginId(), $definition);
}
}

View file

@ -7,6 +7,7 @@
namespace Drupal\menu_link_content\Plugin\migrate\source;
use Drupal\Component\Utility\Unicode;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Row;
@ -23,12 +24,20 @@ class MenuLink extends DrupalSqlBase {
* {@inheritdoc}
*/
public function query() {
return $this->select('menu_links', 'ml')
->fields('ml')
->orderby('ml.depth')
->orderby('ml.mlid')
->condition('module', 'menu')
->condition('customized', 1);
$query = $this->select('menu_links', 'ml')
->fields('ml');
$and = $query->andConditionGroup()
->condition('ml.module', 'menu')
->condition('ml.router_path', ['admin/build/menu-customize/%', 'admin/structure/menu/manage/%'], 'NOT IN');
$condition = $query->orConditionGroup()
->condition('ml.customized', 1)
->condition($and);
$query->condition($condition);
$query->leftJoin('menu_links', 'pl', 'ml.plid = pl.mlid');
$query->addField('pl', 'link_path', 'parent_link_path');
$query->orderBy('ml.depth');
$query->orderby('ml.mlid');
return $query;
}
/**
@ -70,6 +79,7 @@ class MenuLink extends DrupalSqlBase {
public function prepareRow(Row $row) {
$row->setSourceProperty('options', unserialize($row->getSourceProperty('options')));
$row->setSourceProperty('enabled', !$row->getSourceProperty('hidden'));
$row->setSourceProperty('description', Unicode::truncate($row->getSourceProperty('options/attributes/title'), 255));
return parent::prepareRow($row);
}
@ -79,6 +89,7 @@ class MenuLink extends DrupalSqlBase {
*/
public function getIds() {
$ids['mlid']['type'] = 'integer';
$ids['mlid']['alias'] = 'ml';
return $ids;
}

View file

@ -29,7 +29,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
parent::setUp();
$this->installSchema('system', ['router']);
$this->installEntitySchema('menu_link_content');
$this->executeMigrations(['menu', 'd6_menu_links']);
$this->executeMigrations(['menu', 'menu_links']);
}
/**

View file

@ -8,6 +8,8 @@
namespace Drupal\menu_link_content\Tests\Migrate\d7;
use Drupal\Core\Database\Database;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\Url;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\menu_link_content\MenuLinkContentInterface;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
@ -18,6 +20,7 @@ use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
* @group menu_link_content
*/
class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
const MENU_NAME = 'menu-test-menu';
/**
* {@inheritdoc}
@ -32,6 +35,7 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
$this->installSchema('system', ['router']);
$this->installEntitySchema('menu_link_content');
$this->executeMigration('menu');
\Drupal::service('router.builder')->rebuild();
}
/**
@ -70,16 +74,44 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
$this->assertIdentical($attributes, $menu_link->link->options);
$this->assertIdentical($uri, $menu_link->link->uri);
$this->assertIdentical($weight, $menu_link->getWeight());
return $menu_link;
}
/**
* Tests migration of menu links.
*/
public function testMenuLinks() {
$this->executeMigration('d7_menu_links');
$this->assertEntity(467, 'Google', 'menu-test-menu', 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0);
$this->assertEntity(468, 'Yahoo', 'menu-test-menu', 'Yahoo', TRUE, FALSE, ['attributes' => ['title' => 'Yahoo']], 'http://yahoo.com', 0);
$this->assertEntity(469, 'Bing', 'menu-test-menu', 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0);
$this->executeMigration('menu_links');
$this->assertEntity(469, 'Bing', static::MENU_NAME, 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0);
$this->assertEntity(467, 'Google', static::MENU_NAME, 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0);
$this->assertEntity(468, 'Yahoo', static::MENU_NAME, 'Yahoo', TRUE, FALSE, ['attributes' => ['title' => 'Yahoo']], 'http://yahoo.com', 0);
$menu_link_tree_service = \Drupal::service('menu.link_tree');
$parameters = new MenuTreeParameters();
$tree = $menu_link_tree_service->load(static::MENU_NAME, $parameters);
$this->assertEqual(2, count($tree));
$children = 0;
$google_found = FALSE;
foreach ($tree as $menu_link_tree_element) {
$children += $menu_link_tree_element->hasChildren;
if ($menu_link_tree_element->link->getUrlObject()->toString() == 'http://bing.com') {
$this->assertEqual(reset($menu_link_tree_element->subtree)->link->getUrlObject()->toString(), 'http://google.com');
$google_found = TRUE;
}
}
$this->assertEqual(1, $children);
$this->assertTrue($google_found);
// Now find the custom link under a system link.
$parameters->root = 'system.admin_structure';
$tree = $menu_link_tree_service->load(static::MENU_NAME, $parameters);
$found = FALSE;
foreach ($tree as $menu_link_tree_element) {
$this->pass($menu_link_tree_element->link->getUrlObject()->toString());
if ($menu_link_tree_element->link->getTitle() == 'custom link test') {
$found = TRUE;
break;
}
}
$this->assertTrue($found);
}
/**
@ -94,8 +126,8 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
->condition('mlid', 467)
->execute();
$this->executeMigration('d7_menu_links');
$this->assertEntity(467, 'Google', 'menu-test-menu', NULL, TRUE, FALSE, [], 'http://google.com', 0);
$this->executeMigration('menu_links');
$this->assertEntity(467, 'Google', static::MENU_NAME, NULL, TRUE, FALSE, [], 'http://google.com', 0);
}
}

View file

@ -6,6 +6,7 @@
*/
namespace Drupal\Tests\menu_link_content\Unit\Plugin\migrate\source;
use Drupal\Component\Utility\Unicode;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
@ -25,6 +26,92 @@ class MenuLinkSourceTest extends MigrateSqlSourceTestCase {
);
protected $expectedResults = array(
array(
// Customized menu link, provided by system module.
'menu_name' => 'menu-test-menu',
'mlid' => 140,
'plid' => 0,
'link_path' => 'admin/config/system/cron',
'router_path' => 'admin/config/system/cron',
'link_title' => 'Cron',
'options' => array(),
'module' => 'system',
'hidden' => 0,
'external' => 0,
'has_children' => 0,
'expanded' => 0,
'weight' => 0,
'depth' => 0,
'customized' => 1,
'p1' => '0',
'p2' => '0',
'p3' => '0',
'p4' => '0',
'p5' => '0',
'p6' => '0',
'p7' => '0',
'p8' => '0',
'p9' => '0',
'updated' => '0',
),
array(
// D6 customized menu link, provided by menu module.
'menu_name' => 'menu-test-menu',
'mlid' => 141,
'plid' => 0,
'link_path' => 'node/141',
'router_path' => 'node/%',
'link_title' => 'Node 141',
'options' => array(),
'module' => 'menu',
'hidden' => 0,
'external' => 0,
'has_children' => 0,
'expanded' => 0,
'weight' => 0,
'depth' => 0,
'customized' => 1,
'p1' => '0',
'p2' => '0',
'p3' => '0',
'p4' => '0',
'p5' => '0',
'p6' => '0',
'p7' => '0',
'p8' => '0',
'p9' => '0',
'updated' => '0',
'description' => '',
),
array(
// D6 non-customized menu link, provided by menu module.
'menu_name' => 'menu-test-menu',
'mlid' => 142,
'plid' => 0,
'link_path' => 'node/142',
'router_path' => 'node/%',
'link_title' => 'Node 142',
'options' => array(),
'module' => 'menu',
'hidden' => 0,
'external' => 0,
'has_children' => 0,
'expanded' => 0,
'weight' => 0,
'depth' => 0,
'customized' => 0,
'p1' => '0',
'p2' => '0',
'p3' => '0',
'p4' => '0',
'p5' => '0',
'p6' => '0',
'p7' => '0',
'p8' => '0',
'p9' => '0',
'updated' => '0',
'description' => '',
),
array(
'menu_name' => 'menu-test-menu',
'mlid' => 138,
@ -51,6 +138,7 @@ class MenuLinkSourceTest extends MigrateSqlSourceTestCase {
'p8' => '0',
'p9' => '0',
'updated' => '0',
'description' => 'Test menu link 1',
),
array(
'menu_name' => 'menu-test-menu',
@ -78,17 +166,55 @@ class MenuLinkSourceTest extends MigrateSqlSourceTestCase {
'p8' => '0',
'p9' => '0',
'updated' => '0',
'description' => 'Test menu link 2',
),
);
/**
* {@inheritdoc}
*/
public function setUp() {
foreach ($this->expectedResults as $k => $row) {
protected function setUp() {
$this->databaseContents['menu_links'] = $this->expectedResults;
// Add long link title attributes.
$title = $this->getRandomGenerator()->string('500');
$this->databaseContents['menu_links'][0]['options']['attributes']['title'] = $title;
$this->expectedResults[0]['description'] = Unicode::truncate($title, 255);
// D6 menu link to a custom menu, provided by menu module.
$this->databaseContents['menu_links'][] = [
'menu_name' => 'menu-user',
'mlid' => 143,
'plid' => 0,
'link_path' => 'admin/build/menu-customize/navigation',
'router_path' => 'admin/build/menu-customize/%',
'link_title' => 'Navigation',
'options' => array(),
'module' => 'menu',
'hidden' => 0,
'external' => 0,
'has_children' => 0,
'expanded' => 0,
'weight' => 0,
'depth' => 0,
'customized' => 0,
'p1' => '0',
'p2' => '0',
'p3' => '0',
'p4' => '0',
'p5' => '0',
'p6' => '0',
'p7' => '0',
'p8' => '0',
'p9' => '0',
'updated' => '0',
'description' => '',
];
array_walk($this->databaseContents['menu_links'], function (&$row) {
$row['options'] = serialize($row['options']);
$this->databaseContents['menu_links'][$k] = $row;
}
});
parent::setUp();
}