Loading includes/common.inc +6 −0 Changes for includes/common.inc: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8034,8 +8034,14 @@ function entity_extract_ids($entity_type, $entity) { $info = entity_get_info($entity_type); // Objects being created might not have id/vid yet. if (!empty($info)) { $id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL; $vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL; } else { $id = NULL; $vid = NULL; } if (!empty($info['entity keys']['bundle'])) { // Explicitly fail for malformed entities missing the bundle property. Loading modules/field/tests/field.test +12 −0 Changes for modules/field/tests/field.test: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3788,4 +3788,16 @@ class EntityPropertiesTestCase extends FieldTestCase { } } } /** * Tests entity_extract_ids() with an empty entity info. */ function testEntityKeys(){ $entity_type = 'test_entity2'; $entity = field_test_create_stub_entity(); list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); $this->assertNull($id, 'Entity id for test_entity2 returned NULL.'); $this->assertNull($vid, 'Entity vid for test_entity2 returned NULL.'); } } Loading
includes/common.inc +6 −0 Changes for includes/common.inc: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8034,8 +8034,14 @@ function entity_extract_ids($entity_type, $entity) { $info = entity_get_info($entity_type); // Objects being created might not have id/vid yet. if (!empty($info)) { $id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL; $vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL; } else { $id = NULL; $vid = NULL; } if (!empty($info['entity keys']['bundle'])) { // Explicitly fail for malformed entities missing the bundle property. Loading
modules/field/tests/field.test +12 −0 Changes for modules/field/tests/field.test: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3788,4 +3788,16 @@ class EntityPropertiesTestCase extends FieldTestCase { } } } /** * Tests entity_extract_ids() with an empty entity info. */ function testEntityKeys(){ $entity_type = 'test_entity2'; $entity = field_test_create_stub_entity(); list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); $this->assertNull($id, 'Entity id for test_entity2 returned NULL.'); $this->assertNull($vid, 'Entity vid for test_entity2 returned NULL.'); } }