diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 94ce03c..28744be 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -72,7 +72,7 @@ public function uuid() { * {@inheritdoc} */ public function isNew() { - return !empty($this->enforceIsNew) || !$this->id(); + return !empty($this->enforceIsNew) || $this->id() === NULL; } /** diff --git a/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php index b9168d5..78ba0e1 100644 --- a/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php +++ b/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php @@ -66,7 +66,6 @@ public function processDefinition(&$definition, $plugin_id) { } } - /** * Returns the default field-level settings for a field type. * @@ -100,21 +99,22 @@ public function getDefaultInstanceSettings($type) { /** * Gets the definition of all field types. * - * @param Boolean $configurable - * Configurable flag to indicate whether return configurable field types. + * @param bool $configurable + * (optional) Whether to return only configurable field types. Defaults to + * FALSE. * * @return array * An array of field type definitions. */ - public function getDefinitions($configurable = NULL) { + public function getDefinitions($configurable = FALSE) { $definitions = $this->getCachedDefinitions(); if (!isset($definitions)) { $definitions = $this->findDefinitions(); $this->setCachedDefinitions($definitions); } if ($configurable) { - return array_filter($this->definitions, function ($defintion) { - return $defintion['configurable']; + return array_filter($this->definitions, function ($definition) { + return $definition['configurable']; }); } return $definitions; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php b/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php index ea8f916..7cefb45 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php @@ -51,8 +51,8 @@ public function getPropertyDefinitions() { 'label' => t('Comment status value'), ), 'cid' => array( + 'type' => 'integer', 'label' => t('Last comment ID'), - 'type' => 'integer', ), 'last_comment_timestamp' => array( 'label' => t('Last comment timestamp'), diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 5d2632c..6ba7203 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -15,7 +15,7 @@ * Implements hook_field_info_alter(). */ function entity_reference_field_info_alter(&$info) { - // Make he entity reference field configurable. + // Make the entity reference field configurable. $info['entity_reference']['configurable'] = TRUE; $info['entity_reference']['class'] = '\Drupal\entity_reference\Plugin\field\field_type\ConfigurableEntityReferenceItem'; $info['entity_reference']['list_class'] = '\Drupal\field\Plugin\Type\FieldType\ConfigFieldItemList'; diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/field_type/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/field_type/ConfigurableEntityReferenceItem.php index 299780a..491cd16 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/field_type/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/field_type/ConfigurableEntityReferenceItem.php @@ -70,7 +70,7 @@ public function preSave() { $entity = $this->get('entity')->getValue(); $target_id = $this->get('target_id')->getValue(); - if ($target_id === NULL && !empty($entity) && $entity->isNew()) { + if (!$target_id && !empty($entity) && $entity->isNew()) { $entity->save(); $this->set('target_id', $entity->id()); } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 92f8819..638d3af 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -132,8 +132,8 @@ function field_help($path, $arg) { $providers = array_unique($providers); sort($providers); foreach ($providers as $provider) { - // @todo: Throws notices because the owner of field types in - // \Drupal\Core\Entity is 'Core'. + // Skip plugins provided by core components as they do not implement + // hook_help(). if (isset($info[$provider]['name'])) { $display = $info[$provider]['name']; if (\Drupal::moduleHandler()->implementsHook($provider, 'help')) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index 30fea9e..79a143d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -355,8 +355,8 @@ protected function checkIntrospection($entity_type) { // @todo: Make this work without having to create entity objects. $entity = entity_create($entity_type, array()); $definitions = $entity->getPropertyDefinitions(); - $this->assertEqual($definitions['name']['type'], 'string_field', $entity_type .': Name field found.'); - $this->assertEqual($definitions['user_id']['type'], 'entity_reference_field', $entity_type .': User field found.'); + $this->assertEqual($definitions['name']['type'], 'field_item:string', $entity_type .': Name field found.'); + $this->assertEqual($definitions['user_id']['type'], 'field_item:entity_reference', $entity_type .': User field found.'); $this->assertEqual($definitions['field_test_text']['type'], 'field_item:text', $entity_type .': Test-text-field field found.'); // Test introspecting an entity object. @@ -364,8 +364,8 @@ protected function checkIntrospection($entity_type) { $entity = entity_create($entity_type, array()); $definitions = $entity->getPropertyDefinitions(); - $this->assertEqual($definitions['name']['type'], 'string_field', $entity_type .': Name field found.'); - $this->assertEqual($definitions['user_id']['type'], 'entity_reference_field', $entity_type .': User field found.'); + $this->assertEqual($definitions['name']['type'], 'field_item:string', $entity_type .': Name field found.'); + $this->assertEqual($definitions['user_id']['type'], 'field_item:entity_reference', $entity_type .': User field found.'); $this->assertEqual($definitions['field_test_text']['type'], 'field_item:text', $entity_type .': Test-text-field field found.'); $name_properties = $entity->name->getPropertyDefinitions(); diff --git a/core/modules/user/lib/Drupal/user/Entity/User.php b/core/modules/user/lib/Drupal/user/Entity/User.php index 693751e..d8dc8e4 100644 --- a/core/modules/user/lib/Drupal/user/Entity/User.php +++ b/core/modules/user/lib/Drupal/user/Entity/User.php @@ -58,14 +58,6 @@ public function id() { /** * {@inheritdoc} */ - public function isNew() { - // ID 0 does not imply a new user. - return !empty($this->enforceIsNew) || $this->id() === NULL; - } - - /** - * {@inheritdoc} - */ static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) { parent::preCreate($storage_controller, $values); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php index 99aaecb..46037f8 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php @@ -108,10 +108,12 @@ function testValidation() { $mail = $this->randomName(EMAIL_MAX_LENGTH - 11) . '@example.com'; $user->set('mail', $mail); + // @todo: There are two separate violations in case of an invalid e-mail. + // Unifiy field item and field property constraints. $violations = $user->validate(); - $this->assertEqual(count($violations), 1, 'Violation found when email is too long'); + $this->assertEqual(count($violations), 2, 'Violations found when email is too long'); $this->assertEqual($violations[0]->getPropertyPath(), 'mail.0.value'); - $this->assertEqual($violations[0]->getMessage(), t('This value is not a valid email address.')); + $this->assertEqual($violations[1]->getMessage(), t('This value is not a valid email address.')); // Provoke a e-mail collision with an exsiting user. $user->set('mail', 'existing@exmaple.com');