I am getting the following error:

Fatal error: Cannot access empty property in /var/www/html/my_site/sites/all/modules/entity_translation/includes/translation.handler.inc on line 206

I have tried the most recent dev and alpha1 versions, but I get the same error with both. The error appeared when I tried to edit a content type.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

plach’s picture

Status: Active » Postponed (maintainer needs more info)

Please, provide a more meaningful bug report.

Kristen Pol’s picture

Title: Fatal Error » Fatal Error: Cannot access empty property
rv0’s picture

Same here after installing latest dev, couldn't access some non-multilingual nodes any more.

Danny Englander’s picture

I had the same error in the issue summery above happen as a WSOD on the front end of my site after I enabled "file" (Translatable entity types) on:

/admin/config/regional/entity_translation

The error I get after checking that check box and saving is:

Notice: Undefined index: base path in entity_translation_menu_alter() (line 162 of 
/sites/all/modules/entity_translation/entity_translation.module).
Notice: Undefined index: access callback in entity_translation_menu_alter() (line 207 of 
/sites/all/modules/entity_translation/entity_translation.module).
Notice: Undefined index: access arguments in entity_translation_menu_alter() (line 207 of 
/sites/all/modules/entity_translation/entity_translation.module).
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in entity_translation_menu_alter() (line 207 of /sites/all/modules/entity_translation/entity_translation.module).

If I uncheck that checkbox, the WSOD on the front end goes away and I no longer get the backend error.

Danny Englander’s picture

It looks like this could somehow be related to: http://drupal.org/node/1440476

FranckV’s picture

I just had the error when trying to override the system image style "thumbnails"

Fatal error: Cannot access empty property in /home/myhost/www/mydrupalrootfolder/sites/all/modules/entity_translation/includes/translation.handler.inc on line 206

I couldn't visit any page anymore...

I found a similar error that occurred as described in http://drupal.org/node/1032728

The suggested correction was to add :

+  // Make sure the entity_info cache is rebuild after changing the translation
+  // settings.
+  entity_info_cache_clear();

So I tried my luck, just like an apprentice sorcerer, to rewrite :

  /**
   * Read the translation data from the storage.
   */
    public static function loadMultiple($entity_type, $entities) {

    $entity_info = entity_get_info($entity_type);
    $translations_key = $entity_info['entity keys']['translations'];

into

  /**
   * Read the translation data from the storage.
   */
  public static function loadMultiple($entity_type, $entities) {

++    entity_info_cache_clear();
    $entity_info = entity_get_info($entity_type);
    $translations_key = $entity_info['entity keys']['translations'];

and at least I could go back to the web site... but with several bad looking messages. It looks like this is a direction though.

The thumbnail style has been overridden so that you can change its settings.
Error message
Notice : Undefined index: translations in EntityTranslationDefaultHandler::loadMultiple() (line 203 in /home/myhost/www/mydrupalrootfolder/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice : Undefined index: translations in EntityTranslationDefaultHandler::loadMultiple() (line 203 in /home/myhost/www/mydrupalrootfolder/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice : Undefined index: translations in EntityTranslationDefaultHandler::loadMultiple() (line 203 in /home/myhost/www/mydrupalrootfolder/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice : Undefined index: translations in EntityTranslationDefaultHandler::loadMultiple() (line 203 in /home/myhost/www/mydrupalrootfolder/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice : Undefined index: translations in EntityTranslationDefaultHandler::loadMultiple() (line 203 in /home/myhost/www/mydrupalrootfolder/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice : Undefined index: translations in EntityTranslationDefaultHandler::loadMultiple() (line 203 in /home/myhost/www/mydrupalrootfolder/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice : Undefined index: translations in EntityTranslationDefaultHandler::loadMultiple() (line 203 in /home/myhost/www/mydrupalrootfolder/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice : Undefined index: translations in EntityTranslationDefaultHandler::loadMultiple() (line 203 in /home/myhost/www/mydrupalrootfolder/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice : Undefined index: fields in field_info_field_by_ids() (line 664 in /home/myhost/www/mydrupalrootfolder/modules/field/field.info.inc).
Notice : Undefined index: fields in field_info_fields() (line 596 in /home/myhost/www/mydrupalrootfolder/modules/field/field.info.inc).
Warning : Invalid argument supplied for foreach() in field_info_fields() (line 596 in /home/myhost/www/mydrupalrootfolder/modules/field/field.info.inc).
Notice : Undefined index: fields in field_info_fields() (line 596 in /home/myhost/www/mydrupalrootfolder/modules/field/field.info.inc).
Warning : Invalid argument supplied for foreach() in field_info_fields() (line 596 in /home/myhost/www/mydrupalrootfolder/modules/field/field.info.inc).

FranckV’s picture

Not a long term solution : just good enough to be able to revert to non overridden settings.
In the end I had to remove the Entity Translation module. Sorry.

batigol’s picture

Same here: Fatal error: Cannot access empty property in modules\entity_translation\includes\translation.handler.inc on line 206

Steps to reproduce the issue:

1. Install the module.

2. Set "Commerce Product" as translatable at (/admin/config/regional/entity_translation).

3. Cannot access my products that I have created before installing the module - (/admin/commerce/products).

UPDATE:
After run update.php, clear cache, cron, restart localhost server, rebuild permissions and god know what else, the problem is gone for me :)

rtdean93’s picture

Component: Code » Base system

I have had this issue - and know that this is related to having items in your shopping cart that trigger the issue whenever I perform any administrative tasks.

To resolve I clear cache and cron, then run update.php.

To prevent from occurring again - I remove items from my cart.

I have been living with this for a while - since I know how to resolve it - but does anyone know how to fix this?

mojzis’s picture

I am running into the same problem with an entity that was created with eck and thus has a bundle. No cache clearing seems to help. I thing the problem is that the ['entity keys']['translations'] is not set, see my #16 @ #1440476: Argument #2 is not an array in entity_translation_menu_alter().

mojzis’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.02 KB

Attached is a simple patch that moves the setting of the 'translations' before the paths. It doesnt bring back full functionality (has to be done in #1440476: Argument #2 is not an array in entity_translation_menu_alter(), but at least gets rid of the fatal error.

davemybes’s picture

I ran into the same problem when using the Bean module. I had 1.0-alpha1 of ET installed and was trying to figure out how to translate Bean blocks. I went to ET settings and ticked Block in the Entities to be translated and boom, 500 error. I tried several patches, including the latest dev release (June 26), but nothing work except #6 here. I don't see the extra errors mentioned. In fact, everything works perfectly, and I can get a Translate tab on the Bean block.

plach’s picture

#11: emtpy_keys-1370900-11.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, emtpy_keys-1370900-11.patch, failed testing.

plach’s picture

Status: Needs work » Postponed (maintainer needs more info)

Please, confirm this still exists in the latest dev.

mrfelton’s picture

Status: Postponed (maintainer needs more info) » Active

Still a problem with latest dev.

lathan’s picture

The simplest way to reproduce this issue is to call field_info_fields() from hook_entity_load. With entityform_type enabled, then visit the field list of any content type defined.

pbuyle’s picture

I had the same error message, in my case this was caused by the following code flow:

  1. entity_get_info( )
  2. My hook_entity_info_alter() implementation
  3. relation_type_load()
  4. relation_get_types()
  5. relation_type_ensure_instance()
  6. field_info_instance()
  7. _field_info_collate_fields()
  8. ...
  9. entity_translation_field_extra_fields( )
  10. entity_translation_get_handler( )
  11. ...
  12. EntityTranslationDefaultHandler->setEntity( )

In general, nesting calls to field_info_* from hook_entity_info_alter() or hook_entity_info() does not work (see #1416558: hook_entity_info(), hook_schema(), and the field system are strongly bound to each other). Here, entity_translation_get_handler( ) receive an incomplete entity info which has not yet been processed by entity_translation_entity_info_alter (because entity_translation_module_implements_alter moves it at the end of the hook_entity_info_alter implementations list). So the ['entity keys']['translation'] properties of the entity info expected in EntityTranslationDefaultHandler::getTranslationsKey() is not set and the Fatal error: Cannot access empty property error occurs.

A simple workaround for me was to avoid loading the relation type (since it was used to load a type defined in code by the same module, the retrieved value can be hardcoded).

I'm not sure if a general workaround can found to avoid retrieving a entity translation handler while building its entity info, which seems to be the root cause of the error.

eliosh’s picture

Error is also in beta2

If i try to create a new condition in rules, before saving the rule i had the fatal error, on the row inside IF block:

  /**
   * @see EntityTranslationHandlerInterface::setEntity()
   */
  public function setEntity($entity) {
    $this->entity = $entity;

    // Ensure translations data is populated.
    $translations_key = $this->getTranslationsKey();
    if (!isset($this->entity->{$translations_key})) {
      $this->entity->{$translations_key} = self::emptyTranslations();
    }

    // Update bundle and entity id properties.
    list($this->entityId, , $this->bundle) = entity_extract_ids($this->entityType, $this->entity);
  }

In my installation, i have set as translatable entity only the node, and not the user.
The rule i am trying to create is very simple:
event: on user login
condition: check if user has role XXX
action: goto page

Modules: rules 2.2 - entity_translation 1.0-beta2 - drupal 7.21

eliosh’s picture

Priority: Normal » Critical

I can say something more.
I try to set user entity as translatable, and now i have a fatal error for every page. Offending line is 343:

  /**
   * Read the translation data from the storage.
   */
  public static function loadMultiple($entity_type, $entities) {
    $entity_info = entity_get_info($entity_type);
    $translations_key = $entity_info['entity keys']['translations'];

    foreach ($entities as $id => $entity) {
      $entities[$id]->{$translations_key} = self::emptyTranslations();
    }

[...]

I tried a workaround as in comment #6, using entity_info_cache_clear() and now I can browse every page, but can't add that rule.

I tried also to add entity_info_cache_clear() as first command in function setEntity($entity), but no way :-(

eliosh’s picture

Dear mongolito404,
how can i retrieve the code flow as you've done on comment #18?

eliosh’s picture

I found the error.
Using patch for Title module as in [1269076] (patch #27) gives me this error.

Sorry

plach’s picture

Priority: Critical » Normal
Status: Active » Needs review
FileSize
3.52 KB

The attached patch should provide more protection against missing data.

pbuyle’s picture

Enabling XDebug for error report in PHP produce detailed stack traces on fatal error.

klonos’s picture

...this is what is see in my apache error.log:

PHP Fatal error: Cannot access empty property in /var/www/mysite/sites/all/modules/entity_translation/includes/translation.handler.inc on line 716, referer: http://www.mysite.net/el/batch?op=start&id=61

Core and all contrib modules used are updated to their latest dev and I'm on Ubuntu 12.10 x64 running apache 2.2.22/php 5.4.6/mariadb 10.0.1

It happens while #1022558-12: During install, "An AJAX HTTP error occurred. HTTP Result Code: 500..."

klonos’s picture

Title: Fatal Error: Cannot access empty property » Fatal Error: Cannot access empty property in /sites/all/modules/entity_translation/includes/translation.handler.inc

...making this issue easier to find.

plach’s picture

Title: Fatal Error: Cannot access empty property in /sites/all/modules/entity_translation/includes/translation.handler.inc » Fatal Error: Cannot access empty property

Guys, did you try #23? It should prevent things from exploding.

plach’s picture

Title: Fatal Error: Cannot access empty property » Fatal Error: Cannot access empty property in /sites/all/modules/entity_translation/includes/translation.handler.inc

crosspost

klonos’s picture

I applied both #23 and #619542-87: Malformed theme .info files break menu_router generation and all issues were resolved for me (though I think that it wasn't the former that did it).

dcrocks’s picture

You shouldn't use the patch from #619542-87: Malformed theme .info files break menu_router generation as it will never be committed. Even the simpler one at #619542-117: Malformed theme .info files break menu_router generation is probably never going in either. And all this is changing in drupal 8. As soon as you update your site you will lose it. I would keep tracking the issue here and do a clean test of the patch in #23. I think keeping the pressure on here is your best chance of cleaning this up.

plach’s picture

Status: Needs review » Reviewed & tested by the community

I am going to commit #23 soon, since it's probably a better solution even if it doesn't fully fix the issue(s) originating the fatals reported here.

plach’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed #23.

Tentatively marking fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 7dfbca8 on 7.x-1.x, factory, et-fc, revisions by plach:
    Issue #1370900 by mojzis, plach | mgladding: Fixed Fatal Error: Cannot...

  • Commit 7dfbca8 on 7.x-1.x, factory, et-fc, revisions, workbench by plach:
    Issue #1370900 by mojzis, plach | mgladding: Fixed Fatal Error: Cannot...