EntityMalformedException: There is no package property for an object of type student. in entity_extract_ids ()

I am creating a simple module called “student”, this module generates a new object - “student”, and this is my code Download here

but when I add a new student, I get an error:

EntityMalformedException: Missing package property in an entity of type student. in entity_extract_ids () (line 7501 from C: \ AppServ \ www \ drupal-7.12 \ includes \ common.inc).

I look through all my code, but I can’t find out anything, Thank you very much!

+3
source share
5 answers

- . , . , , : # 5, :

, , , entity-type -. , "file_managed" "type". , , . , ( ), ...

+5

common.inc Drupal :

  if (!empty($info['entity keys']['bundle'])) {
    // Explicitly fail for malformed entities missing the bundle property.
    if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
      throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
    }
    $bundle = $entity->{$info['entity keys']['bundle']};
  }

, , bundle , , () .

, , .

( drush, PHP- /devel/php, Devel ).

  • , bundle entity keys , , :

    drush eval 'print_r(entity_get_info("student"));'
    
  • type, , , , type.

entity_load() , , , .

, , , :

drush eval '$entity = entity_load("student", array(1)); entity_get_controller("student")->save(reset($entity))'

- entity_type, 1 - .

- , (entity_info_cache_clear()) common.inc (, var_dump($entity); $entity , , type.


: EntityMalformedException? DO

+3

, node nid . , / node.

+1

I have the same problem with the Import User module . I solved it this patch in the user import module. Hope this solution helps you.

0
source

add

var_dump(debug_backtrace());

immediately before the error, you will get more information about the error. which can help you solve this problem.

and check table display identifier some of them are missing ...

0
source

All Articles