When using the media module and editing a file at media/%file/edit/ajax, we get the following PHP notice:

Notice: Undefined offset: 0 in EntityTranslationDefaultHandler->entityForm() (line 722 of /shared/vash/sandboxes/reid/som/www/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice: Trying to get property of non-object in EntityTranslationDefaultHandler->entityForm() (line 722 of /shared/vash/sandboxes/reid/som/www/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice: Undefined offset: 0 in EntityTranslationDefaultHandler->entityForm() (line 722 of /shared/vash/sandboxes/reid/som/www/sites/all/modules/entity_translation/includes/translation.handler.inc).
Notice: Trying to get property of non-object in EntityTranslationDefaultHandler->entityForm() (line 722 of /shared/vash/sandboxes/reid/som/www/sites/all/modules/entity_translation/includes/translation.handler.inc).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

This is because Media module provides an alternative form for editing files, so entity_translation doesn't take over the menu callback. Entities can have more than one form ID for editing. Since getFormLanguage() seems to need to always return a valid value, it should return LANGUAGE_NONE in case $this->formLanguage being empty.

Dave Reid’s picture

Status: Active » Needs review
FileSize
525 bytes

There may be further issues with form submissions or validation that I'm not checking here, but this at least fixes the PHP notice. An alternative to this would be to declare LANGUAGE_NONE as the default of $this->formLanguage in the constructor by default rather than FALSE.

Status: Needs review » Needs work

The last submitted patch, 1728674-php-notice-form-language.patch, failed testing.

plach’s picture

I think originally the point of returning FALSE was being able to tell whether the form language was set or not, but I ain't sure it's such a valuable information after all. However the correct fallback value if form language is missing should be the entity language, which is returned by EntityTranslationHandlerInterface::getLanguage().

This is because Media module provides an alternative form for editing files, so entity_translation doesn't take over the menu callback.

IIRC media integration will need some adjustments in ET to be fixed, since it requires multiple base paths to be definable/defined.

plach’s picture

Status: Needs work » Needs review
FileSize
533 bytes

Let's try this one.

Dave Reid’s picture

IIRC media integration will need some adjustments in ET to be fixed, since it requires multiple base paths to be definable/defined.

Any idea where I should be looking for this?

plach’s picture

This is the issue: #1418076: Allow for multiple base paths. I think you should start looking at entity_translation.api.php for the description of the keys and then look at entity_translation_menu_alter() to see how the 'base path' key is used. I think we should allow it to be an array, but keep the possibility to have a single string value for BC. Note also that the base path is used as default to construct the edit and view paths (which are used to generate UI links), which instead need to be unique. I'd just choose the first available base path in that case.

plach’s picture

Btw, I assume that #5 fixes the notices as well, right?

Dave Reid’s picture

Yep #5 fixes the PHP notice for now.

plach’s picture

Status: Needs review » Fixed

Committed and pushed, thanks.

Status: Fixed » Closed (fixed)

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

bforchhammer’s picture

I think originally the point of returning FALSE was being able to tell whether the form language was set or not, but I ain't sure it's such a valuable information after all.

Note that hook_menu_local_tasks_alter() was relying on that information... see #1770202: Local tasks (language tabs) visible on node view page.

  • Commit 05a33a9 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions authored by Dave Reid, committed by plach:
    Issue #1728674 by Dave Reid, plach: Fixed PHP notice when formLanguage...

  • Commit 05a33a9 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench authored by Dave Reid, committed by plach:
    Issue #1728674 by Dave Reid, plach: Fixed PHP notice when formLanguage...