Commit 2da50857 authored by Dries's avatar Dries

Issue #2285349 by olli: Fixed Fatal error: Call to a member function getType()...

Issue #2285349 by olli: Fixed Fatal error: Call to a member function getType() on a non-object in comment.module on line 951.
parent e9bb4a20
......@@ -863,6 +863,9 @@ function comment_entity_predelete(EntityInterface $entity) {
function _comment_entity_uses_integer_id($entity_type_id) {
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
$entity_type_id_key = $entity_type->getKey('id');
if ($entity_type_id_key === FALSE) {
return FALSE;
}
$field_definitions = \Drupal::entityManager()->getBaseFieldDefinitions($entity_type->id());
$entity_type_id_definition = $field_definitions[$entity_type_id_key];
return $entity_type_id_definition->getType() === 'integer';
......
......@@ -433,6 +433,15 @@ public function testsStringIdEntities() {
$this->drupalLogin($limited_user);
// Visit the Field UI overview.
$this->drupalGet('entity_test_string_id/structure/entity_test/fields');
// Ensure field isn't shown for empty IDs.
$this->assertNoOption('edit-fields-add-new-field-type', 'comment');
entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test_no_id');
$this->drupalLogin($this->drupalCreateUser(array(
'administer entity_test_no_id fields',
)));
// Visit the Field UI overview.
$this->drupalGet('entity_test_no_id/structure/entity_test/fields');
// Ensure field isn't shown for string ids.
$this->assertNoOption('edit-fields-add-new-field-type', 'comment');
}
......
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestNoId.
*/
namespace Drupal\entity_test\Entity;
/**
* Test entity class.
*
* @ContentEntityType(
* id = "entity_test_no_id",
* label = @Translation("Entity Test without id"),
* controllers = {
* "storage" = "Drupal\Core\Entity\ContentEntityNullStorage",
* },
* fieldable = TRUE,
* entity_keys = {
* "bundle" = "type",
* },
* links = {
* "admin-form" = "entity_test.admin_entity_test_no_id"
* }
* )
*/
class EntityTestNoId extends EntityTest {
}
......@@ -23,6 +23,7 @@ class EntityTestRoutes {
public function routes() {
$types = entity_test_entity_types();
$types[] = 'entity_test_string_id';
$types[] = 'entity_test_no_id';
$routes = array();
foreach ($types as $entity_type) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment