Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -0,0 +1,32 @@
<?php
/**
* @file
* Update functions for the path module.
*/
/**
* @addtogroup updates-8.2.0
* @{
*/
/**
* Change the path field to computed for node and taxonomy_term.
*/
function path_update_8200() {
$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
foreach (['node', 'taxonomy_term'] as $entity_type_id) {
if ($entity_definition_update_manager->getEntityType($entity_type_id)) {
// Computed field definitions are not tracked by the entity definition
// update manager, so remove them.
$storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('path', $entity_type_id);
if ($storage_definition) {
$entity_definition_update_manager->uninstallFieldStorageDefinition($storage_definition);
}
}
}
}
/**
* @} End of "addtogroup updates-8.2.0".
*/

View file

@ -5,7 +5,6 @@
* Enables users to rename URLs.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Form\FormStateInterface;
@ -72,19 +71,8 @@ function path_entity_base_field_info(EntityTypeInterface $entity_type) {
'weight' => 30,
))
->setDisplayConfigurable('form', TRUE)
->setCustomStorage(TRUE);
->setComputed(TRUE);
return $fields;
}
}
/**
* Implements hook_entity_translation_delete().
*/
function path_entity_translation_delete(EntityInterface $translation) {
if ($translation->hasLinkTemplate('canonical')) {
$path = $translation->urlInfo()->getInternalPath();
$conditions = array('source' => '/' . $path, 'langcode' => $translation->language()->getId());
\Drupal::service('path.alias_storage')->delete($conditions);
}
}

View file

@ -38,7 +38,6 @@ class PathFilterForm extends FormBase {
);
$form['basic']['submit'] = array(
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => $this->t('Filter'),
);
if ($keys) {

View file

@ -111,7 +111,7 @@ abstract class PathFormBase extends FormBase {
'#default_value' => $this->path['alias'],
'#maxlength' => 255,
'#size' => 45,
'#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page. Use a relative path with a slash in front.'),
'#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.'),
'#field_prefix' => $this->requestContext->getCompleteBaseUrl(),
'#required' => TRUE,
);

View file

@ -21,4 +21,17 @@ class PathFieldItemList extends FieldItemList {
return AccessResult::allowedIfHasPermissions($account, ['create url aliases', 'administer url aliases'], 'OR')->cachePerPermissions();
}
/**
* {@inheritdoc}
*/
public function delete() {
// Delete all aliases associated with this entity in the current language.
$entity = $this->getEntity();
$conditions = [
'source' => '/' . $entity->toUrl()->getInternalPath(),
'langcode' => $entity->language()->getId(),
];
\Drupal::service('path.alias_storage')->delete($conditions);
}
}

View file

@ -28,7 +28,7 @@ class PathItem extends FieldItemBase {
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties['alias'] = DataDefinition::create('string')
->setLabel(t('Path alias'));
$properties['pid'] = DataDefinition::create('string')
$properties['pid'] = DataDefinition::create('integer')
->setLabel(t('Path id'));
return $properties;
}
@ -72,15 +72,6 @@ class PathItem extends FieldItemBase {
}
}
/**
* {@inheritdoc}
*/
public function delete() {
// Delete all aliases associated with this entity.
$entity = $this->getEntity();
\Drupal::service('path.alias_storage')->delete(array('source' => '/' . $entity->urlInfo()->getInternalPath()));
}
/**
* {@inheritdoc}
*/

View file

@ -53,7 +53,7 @@ class PathWidget extends WidgetBase {
'#default_value' => $path['alias'],
'#required' => $element['#required'],
'#maxlength' => 255,
'#description' => $this->t('The alternative URL for this content. Use a relative path. For example, enter "/about" for the about page.'),
'#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.'),
);
$element['pid'] = array(
'#type' => 'value',

View file

@ -43,7 +43,7 @@ class PathAliasTest extends PathTestBase {
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
// Check the path alias whitelist cache.
$whitelist = \Drupal::cache()->get('path_alias_whitelist');
$whitelist = \Drupal::cache('bootstrap')->get('path_alias_whitelist');
$this->assertTrue($whitelist->data['node']);
$this->assertFalse($whitelist->data['admin']);
@ -314,6 +314,18 @@ class PathAliasTest extends PathTestBase {
$this->drupalGet(trim($edit['path[0][alias]'], '/'));
$this->assertText($node4->label(), 'Alias trimmed trailing slash.');
$this->assertResponse(200);
// Create fifth test node.
$node5 = $this->drupalCreateNode();
// Set a path alias.
$edit = array('path[0][alias]' => '/' . $this->randomMachineName(8));
$this->drupalPostForm('node/' . $node5->id() . '/edit', $edit, t('Save'));
// Delete the node and check that the path alias is also deleted.
$node5->delete();
$path_alias = \Drupal::service('path.alias_storage')->lookupPathAlias('/node/' . $node5->id(), $node5->language()->getId());
$this->assertFalse($path_alias, 'Alias was successfully deleted when the referenced node was deleted.');
}
/**

View file

@ -186,6 +186,11 @@ class PathLanguageTest extends PathTestBase {
$english_node->removeTranslation('fr');
$english_node->save();
$this->assertFalse($this->container->get('path.alias_storage')->aliasExists('/' . $french_alias, 'fr'), 'Alias for French translation is removed when translation is deleted.');
// Check that the English alias still works.
$this->drupalGet($english_alias);
$this->assertTrue($this->container->get('path.alias_storage')->aliasExists('/' . $english_alias, 'en'), 'English alias is not deleted when French translation is removed.');
$this->assertText($english_node->body->value, 'English alias still works');
}
}

View file

@ -29,7 +29,7 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
/**
* Assert a path.
*
* @param string pid
* @param string $pid
* The path id.
* @param array $conditions
* The path conditions.

View file

@ -15,7 +15,6 @@ class UrlAliasTest extends UrlAliasTestBase {
protected $migrationConfiguration = array(
'id' => 'test',
'highWaterProperty' => array('field' => 'test'),
'source' => array(
'plugin' => 'd6_url_alias',
),