English 中文(简体)
实体多元例外: 实体类型学生实体丢失的捆包属性。 实体_ extract_ ids ()
原标题:EntityMalformedException: Missing bundle property on entity of type student. in entity_extract_ids()

I create simple module named "student" , this module generate new entity is "student" and this is my code Download here

但当我加入新学生时, 我收到一个错误信息:

实体MAFFIDException: 在实体_Extract_ids () 中缺少学生类型实体的捆包属性(C行75001:AppServwwwdrupal-7.12包含common.inc)。

I look through all of my code but I can t find out some thing, Thank alot!

问题回答

这个问题 - < a href=""" "http://drupal.org/node/1266620" rel="nofollow" > missing捆绑属性在类型文件错误 - 的实体上可能是造成你问题的原因。

I have the same issue which is obviously caused by a missing entity-type-property in an entity-object. I took a look into my database and discovered that the table "file_managed" has a field "type". I filled in the type of the entity object in question and it works. Obviously this is not a real solution (updating the database manually), because there exist hundreds of entries...

Drupal Core common.inc 文件抛出错误, 条件如下:

  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) 。

有许多原因,这可能会失败,所以你必须先分析一下。

(如果您没有刷子,如果启用 Devil 模块,您可以在 /devel/php 中运行 PHP 代码) 。

  1. 检查 bundle entity keys 中的 值。 ”

    drush eval  print_r(entity_get_info("student")); 
    
  2. 如果 s type ,那么这意味着您试图保存的实体,则缺少 type 属性。

常见的错误是通常通过