diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php index 107495b..537fb79 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php @@ -413,7 +413,10 @@ public function addField($table, $field, $spec, $keys_new = array()) { } if ($fixnull) { $spec['not null'] = TRUE; - $this->changeField($table, $field, $field, $spec); + $count = $this->connection->query('SELECT COUNT(*) AS count FROM {' . $table . '}')->fetchAssoc(); + if ($count['count'] == 0) { + $this->changeField($table, $field, $field, $spec); + } } } diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install index d6093d8..c612fd8 100644 --- a/core/modules/aggregator/aggregator.install +++ b/core/modules/aggregator/aggregator.install @@ -42,11 +42,11 @@ function aggregator_update_8001() { * Update schema. */ function aggregator_update_8002() { - $entity_type = \Drupal::entityTypeManager()->getStorage('feed')->getEntityType(); + $entity_type = \Drupal::entityTypeManager()->getStorage('aggregator_feed')->getEntityType(); \Drupal::service('system.entity_schema_updater')->createTables($entity_type); \Drupal::service('system.entity_schema_updater')->addRevisionField($entity_type); - $entity_type = \Drupal::entityTypeManager()->getStorage('item')->getEntityType(); + $entity_type = \Drupal::entityTypeManager()->getStorage('aggregator_item')->getEntityType(); \Drupal::service('system.entity_schema_updater')->createTables($entity_type); \Drupal::service('system.entity_schema_updater')->addRevisionField($entity_type); } diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php index 10e57c1..bc790c6 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -143,6 +143,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Title')) ->setDescription(t('The name of the feed (or the name of the website providing the feed).')) ->setRequired(TRUE) + ->setRevisionable(TRUE) ->setSetting('max_length', 255) ->setDisplayOptions('form', array( 'type' => 'string_textfield', @@ -155,6 +156,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('URL')) ->setDescription(t('The fully-qualified URL of the feed.')) ->setRequired(TRUE) + ->setRevisionable(TRUE) ->setDisplayOptions('form', array( 'type' => 'uri', 'weight' => -3, @@ -171,6 +173,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDescription(t('The length of time between feed updates. Requires a correctly configured cron maintenance task.')) ->setSetting('unsigned', TRUE) ->setRequired(TRUE) + ->setRevisionable(TRUE) ->setSetting('allowed_values', $period) ->setDisplayOptions('form', array( 'type' => 'options_select', @@ -182,6 +185,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Checked')) ->setDescription(t('Last time feed was checked for new items, as Unix timestamp.')) ->setDefaultValue(0) + ->setRevisionable(TRUE) ->setDisplayOptions('view', array( 'label' => 'inline', 'type' => 'timestamp_ago', @@ -192,11 +196,13 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['queued'] = BaseFieldDefinition::create('timestamp') ->setLabel(t('Queued')) ->setDescription(t('Time when this feed was queued for refresh, 0 if not queued.')) - ->setDefaultValue(0); + ->setDefaultValue(0) + ->setRevisionable(TRUE); $fields['link'] = BaseFieldDefinition::create('uri') ->setLabel(t('URL')) ->setDescription(t('The link of the feed.')) + ->setRevisionable(TRUE) ->setDisplayOptions('view', array( 'label' => 'inline', 'weight' => 4, @@ -205,26 +211,31 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['description'] = BaseFieldDefinition::create('string_long') ->setLabel(t('Description')) - ->setDescription(t("The parent website's description that comes from the @description element in the feed.", array('@description' => ''))); + ->setDescription(t("The parent website's description that comes from the @description element in the feed.", array('@description' => ''))) + ->setRevisionable(TRUE); $fields['image'] = BaseFieldDefinition::create('uri') ->setLabel(t('Image')) - ->setDescription(t('An image representing the feed.')); + ->setDescription(t('An image representing the feed.')) + ->setRevisionable(TRUE); $fields['hash'] = BaseFieldDefinition::create('string') ->setLabel(t('Hash')) ->setSetting('is_ascii', TRUE) - ->setDescription(t('Calculated hash of the feed data, used for validating cache.')); + ->setDescription(t('Calculated hash of the feed data, used for validating cache.')) + ->setRevisionable(TRUE); $fields['etag'] = BaseFieldDefinition::create('string') ->setLabel(t('Etag')) - ->setDescription(t('Entity tag HTTP response header, used for validating cache.')); + ->setDescription(t('Entity tag HTTP response header, used for validating cache.')) + ->setRevisionable(TRUE); // This is updated by the fetcher and not when the feed is saved, therefore // it's a timestamp and not a changed field. $fields['modified'] = BaseFieldDefinition::create('timestamp') ->setLabel(t('Modified')) - ->setDescription(t('When the feed was last modified, as a Unix timestamp.')); + ->setDescription(t('When the feed was last modified, as a Unix timestamp.')) + ->setRevisionable(TRUE); return $fields; } diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index ff3bf41..24b458a 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -235,6 +235,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['subject'] = BaseFieldDefinition::create('string') ->setLabel(t('Subject')) ->setTranslatable(TRUE) + ->setRevisionable(TRUE) ->setSetting('max_length', 64) ->setDisplayOptions('form', array( 'type' => 'string_textfield', @@ -247,6 +248,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('User ID')) ->setDescription(t('The user ID of the comment author.')) ->setTranslatable(TRUE) + ->setRevisionable(TRUE) ->setSetting('target_type', 'user') ->setDefaultValue(0); @@ -254,18 +256,21 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Name')) ->setDescription(t("The comment author's name.")) ->setTranslatable(TRUE) + ->setRevisionable(TRUE) ->setSetting('max_length', 60) ->setDefaultValue(''); $fields['mail'] = BaseFieldDefinition::create('email') ->setLabel(t('Email')) ->setDescription(t("The comment author's email address.")) - ->setTranslatable(TRUE); + ->setTranslatable(TRUE) + ->setRevisionable(TRUE); $fields['homepage'] = BaseFieldDefinition::create('uri') ->setLabel(t('Homepage')) ->setDescription(t("The comment author's home page address.")) ->setTranslatable(TRUE) + ->setRevisionable(TRUE) // URIs are not length limited by RFC 2616, but we can only store 255 // characters in our comment DB schema. ->setSetting('max_length', 255); @@ -274,22 +279,26 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Hostname')) ->setDescription(t("The comment author's hostname.")) ->setTranslatable(TRUE) + ->setRevisionable(TRUE) ->setSetting('max_length', 128); $fields['created'] = BaseFieldDefinition::create('created') ->setLabel(t('Created')) ->setDescription(t('The time that the comment was created.')) - ->setTranslatable(TRUE); + ->setTranslatable(TRUE) + ->setRevisionable(TRUE); $fields['changed'] = BaseFieldDefinition::create('changed') ->setLabel(t('Changed')) ->setDescription(t('The time that the comment was last edited.')) - ->setTranslatable(TRUE); + ->setTranslatable(TRUE) + ->setRevisionable(TRUE); $fields['status'] = BaseFieldDefinition::create('boolean') ->setLabel(t('Publishing status')) ->setDescription(t('A boolean indicating whether the comment is published.')) ->setTranslatable(TRUE) + ->setRevisionable(TRUE) ->setDefaultValue(TRUE); $fields['thread'] = BaseFieldDefinition::create('string') diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php index 88e2fbe..8d4a921 100644 --- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php @@ -254,6 +254,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDescription(t('The text to be used for this link in the menu.')) ->setRequired(TRUE) ->setTranslatable(TRUE) + ->setRevisionable(TRUE) ->setSetting('max_length', 255) ->setDisplayOptions('view', array( 'label' => 'hidden', @@ -270,6 +271,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Description')) ->setDescription(t('Shown when hovering over the menu link.')) ->setTranslatable(TRUE) + ->setRevisionable(TRUE) ->setSetting('max_length', 255) ->setDisplayOptions('view', array( 'label' => 'hidden', @@ -359,7 +361,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['changed'] = BaseFieldDefinition::create('changed') ->setLabel(t('Changed')) ->setDescription(t('The time that the menu link was last edited.')) - ->setTranslatable(TRUE); + ->setTranslatable(TRUE) + ->setRevisionable(TRUE); return $fields; } diff --git a/core/modules/system/src/EntitySchemaUpdater.php b/core/modules/system/src/EntitySchemaUpdater.php index 9e11cee..7af9bb5 100644 --- a/core/modules/system/src/EntitySchemaUpdater.php +++ b/core/modules/system/src/EntitySchemaUpdater.php @@ -23,7 +23,8 @@ public function addRevisionField(EntityTypeInterface $entity_type) { $storage_definition = BaseFieldDefinition::create('integer') ->setLabel(new TranslatableMarkup('Revision ID')) ->setReadOnly(TRUE) - ->setSetting('unsigned', TRUE); + ->setSetting('unsigned', TRUE) + ->setDefaultValue(1); \Drupal::entityDefinitionUpdateManager() ->installFieldStorageDefinition($entity_type->getKey('revision'), $entity_type->id(), $entity_type->id(), $storage_definition); } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index cdaeba6..20489ca 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1128,11 +1128,11 @@ function system_update_8004() { // langcode) compound index, but this update function wasn't added until // https://www.drupal.org/node/2542748. Regenerate the related schemas to // ensure they match the currently expected status. - $manager = \Drupal::entityDefinitionUpdateManager(); - foreach (array_keys(\Drupal::entityManager() - ->getDefinitions()) as $entity_type_id) { - $manager->updateEntityType($manager->getEntityType($entity_type_id)); - } + //$manager = \Drupal::entityDefinitionUpdateManager(); + //foreach (array_keys(\Drupal::entityManager() + // ->getDefinitions()) as $entity_type_id) { + // $manager->updateEntityType($manager->getEntityType($entity_type_id)); + //} } /** diff --git a/core/modules/taxonomy/src/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php index 7a9e3bd..8ebc717 100644 --- a/core/modules/taxonomy/src/Entity/Term.php +++ b/core/modules/taxonomy/src/Entity/Term.php @@ -119,6 +119,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Name')) ->setDescription(t('The term name.')) ->setTranslatable(TRUE) + ->setRevisionable(TRUE) ->setRequired(TRUE) ->setSetting('max_length', 255) ->setDisplayOptions('view', array( @@ -164,7 +165,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['changed'] = BaseFieldDefinition::create('changed') ->setLabel(t('Changed')) ->setDescription(t('The time that the term was last edited.')) - ->setTranslatable(TRUE); + ->setTranslatable(TRUE) + ->setRevisionable(TRUE); return $fields; }