Skip to content
Snippets Groups Projects
Commit 956af788 authored by Damian Lee's avatar Damian Lee Committed by Tim Plunkett
Browse files

Issue #1768392 by damiankloip, dawehner: Fixed Views do not create uuids for...

Issue #1768392 by damiankloip, dawehner: Fixed Views do not create uuids for existing views or save any uuid.
parent 2660450b
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -171,6 +171,7 @@ function views_test_between() {
$view->core = 8;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$view->uuid = NULL;
/* Display: Master */
$handler = $view->newDisplay('default', 'Master', 'default');
......
......@@ -112,6 +112,7 @@ public function viewsStorePagerSettings() {
$view->is_cacheable = FALSE;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$view->uuid = NULL;
/* Display: Master */
$handler = $view->newDisplay('default', 'Master', 'default');
......
......@@ -150,6 +150,7 @@ public function view_unpack_translatable() {
$view->base_table = 'node';
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$view->uuid = NULL;
/* Display: Master */
$handler = $view->newDisplay('default', 'Master1', 'default');
......
......@@ -130,6 +130,10 @@ protected function loadTests() {
// Check that all of these machine names match.
$this->assertIdentical(array_keys($all_configuration_entities), array_map($prefix_map, $all_config), 'All loaded elements match.');
// Make sure that loaded default views get a uuid.
$view = views_get_view('frontpage');
$this->assertTrue($view->uuid());
}
/**
......@@ -166,6 +170,11 @@ protected function createTests() {
$this->assertTrue($display instanceof ViewDisplay, format_string('Display @display is an instance of ViewDisplay.', array('@display' => $key)));
}
// Check the uuid of the loaded View.
$created->set('name', 'glossary_new');
$created->save();
$created_loaded = $this->loadView('glossary_new');
$this->assertIdentical($created->uuid(), $created_loaded->uuid(), 'The created uuid has been saved correctly.');
}
/**
......
......@@ -9,17 +9,33 @@
use Drupal\config\ConfigStorageController;
use Drupal\entity\EntityInterface;
use Drupal\Component\Uuid\Uuid;
/**
* Defines the storage controller class for ViewStorage entities.
*/
class ViewStorageController extends ConfigStorageController {
/**
* Holds a UUID factory instance.
*
* @var Drupal\Component\Uuid\Uuid
*/
protected $uuidFactory = NULL;
/**
* Overrides Drupal\config\ConfigStorageController::attachLoad();
*/
protected function attachLoad(&$queried_entities, $revision_id = FALSE) {
foreach ($queried_entities as $id => $entity) {
// Create a uuid if we don't have one.
if (empty($entity->{$this->uuidKey})) {
// Only get an instance of uuid once.
if (!isset($this->uuidFactory)) {
$this->uuidFactory = new Uuid();
}
$entity->{$this->uuidKey} = $this->uuidFactory->generate();
}
// @todo This property is left in for CTools export UI.
$entity->type = t('Normal');
$this->attachDisplays($entity);
......@@ -65,6 +81,7 @@ public function save(EntityInterface $entity) {
'human_name',
'core',
'display',
'uuid',
);
foreach ($config_properties as $property) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment