Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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).
Comment | File | Size | Author |
---|---|---|---|
#5 | et-form_language_false-1728674-5.patch | 533 bytes | plach |
#2 | 1728674-php-notice-form-language.patch | 525 bytes | Dave Reid |
Comments
Comment #1
Dave ReidThis 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.
Comment #2
Dave ReidThere 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.
Comment #4
plachI 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()
.IIRC media integration will need some adjustments in ET to be fixed, since it requires multiple base paths to be definable/defined.
Comment #5
plachLet's try this one.
Comment #6
Dave ReidAny idea where I should be looking for this?
Comment #7
plachThis 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 atentity_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.Comment #8
plachBtw, I assume that #5 fixes the notices as well, right?
Comment #9
Dave ReidYep #5 fixes the PHP notice for now.
Comment #10
plachCommitted and pushed, thanks.
Comment #12
bforchhammer CreditAttribution: bforchhammer commentedNote that
hook_menu_local_tasks_alter()
was relying on that information... see #1770202: Local tasks (language tabs) visible on node view page.