Update to Drupal 8.2.6. For more information, see https://www.drupal.org/project/drupal/releases/8.2.6
This commit is contained in:
parent
db56c09587
commit
f1e72395cb
588 changed files with 26857 additions and 2777 deletions
|
|
@ -20,5 +20,17 @@ process:
|
|||
langcode:
|
||||
plugin: d6_url_alias_language
|
||||
source: language
|
||||
node_translation:
|
||||
-
|
||||
plugin: explode
|
||||
source: src
|
||||
delimiter: /
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_node_translation
|
||||
destination:
|
||||
plugin: url_alias
|
||||
|
|
|
|||
|
|
@ -59,13 +59,21 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function import(Row $row, array $old_destination_id_values = array()) {
|
||||
$source = $row->getDestinationProperty('source');
|
||||
$alias = $row->getDestinationProperty('alias');
|
||||
$langcode = $row->getDestinationProperty('langcode');
|
||||
$pid = $old_destination_id_values ? $old_destination_id_values[0] : NULL;
|
||||
|
||||
$path = $this->aliasStorage->save(
|
||||
$row->getDestinationProperty('source'),
|
||||
$row->getDestinationProperty('alias'),
|
||||
$row->getDestinationProperty('langcode'),
|
||||
$old_destination_id_values ? $old_destination_id_values[0] : NULL
|
||||
);
|
||||
// Check if this alias is for a node and if that node is a translation.
|
||||
if (preg_match('/^\/node\/\d+$/', $source) && $row->hasDestinationProperty('node_translation')) {
|
||||
|
||||
// Replace the alias source with the translation source path.
|
||||
$node_translation = $row->getDestinationProperty('node_translation');
|
||||
$source = '/node/' . $node_translation[0];
|
||||
$langcode = $node_translation[1];
|
||||
}
|
||||
|
||||
$path = $this->aliasStorage->save($source, $alias, $langcode, $pid);
|
||||
|
||||
return array($path['pid']);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,11 @@ abstract class UrlAliasBase extends DrupalSqlBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('url_alias', 'ua')->fields('ua');
|
||||
// The order of the migration is significant since
|
||||
// \Drupal\Core\Path\AliasStorage::lookupPathAlias() orders by pid before
|
||||
// returning a result. Postgres does not automatically order by primary key
|
||||
// therefore we need to add a specific order by.
|
||||
return $this->select('url_alias', 'ua')->fields('ua')->orderBy('pid');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,14 +16,26 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('path');
|
||||
public static $modules = ['language', 'content_translation', 'path'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_url_alias');
|
||||
$this->installEntitySchema('node');
|
||||
$this->installConfig(['node']);
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->migrateUsers(FALSE);
|
||||
$this->migrateFields();
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_node_settings',
|
||||
'd6_node',
|
||||
'd6_node_translation',
|
||||
'd6_url_alias',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,4 +105,33 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
|
|||
$this->assertPath('3', $conditions, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the URL alias migration with translated nodes.
|
||||
*/
|
||||
public function testUrlAliasWithTranslatedNodes() {
|
||||
$alias_storage = $this->container->get('path.alias_storage');
|
||||
|
||||
// Alias for the 'The Real McCoy' node in English.
|
||||
$path = $alias_storage->load(['alias' => '/the-real-mccoy']);
|
||||
$this->assertSame('/node/10', $path['source']);
|
||||
$this->assertSame('en', $path['langcode']);
|
||||
|
||||
// Alias for the 'The Real McCoy' French translation,
|
||||
// which should now point to node/10 instead of node/11.
|
||||
$path = $alias_storage->load(['alias' => '/le-vrai-mccoy']);
|
||||
$this->assertSame('/node/10', $path['source']);
|
||||
$this->assertSame('fr', $path['langcode']);
|
||||
|
||||
// Alias for the 'Abantu zulu' node in Zulu.
|
||||
$path = $alias_storage->load(['alias' => '/abantu-zulu']);
|
||||
$this->assertSame('/node/12', $path['source']);
|
||||
$this->assertSame('zu', $path['langcode']);
|
||||
|
||||
// Alias for the 'Abantu zulu' English translation,
|
||||
// which should now point to node/12 instead of node/13.
|
||||
$path = $alias_storage->load(['alias' => '/the-zulu-people']);
|
||||
$this->assertSame('/node/12', $path['source']);
|
||||
$this->assertSame('en', $path['langcode']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue