I have a multilingual site and use admin_language to have a Dutch admin language for all sites (4 languages in total). I use the Media module (7.x-2.0-alpha4) to select images in a content-type using the media popup.
When adding a new node (not editing an existing one) and selecting an image, a wrong callback is placed on the button which causes the node to get saved. This callback is executed because the core functionality of Drupal core thinks the form is submitted via Ajax.
For Drupal 7.34 this gets executed in this function (includes/form.inc:2127)
function _form_element_triggered_scripted_submission($element, &$form_state) {
if (!empty($form_state['input']['_triggering_element_name']) && $element['#name'] == $form_state['input']['_triggering_element_name']) {
if (empty($form_state['input']['_triggering_element_value']) || $form_state['input']['_triggering_element_value'] == $element['#value']) {
return TRUE;
}
}
return FALSE;
}
While debugging I discovered that the $form_state['input']['_triggering_element_value'] and $element['#value'] should contain the text of the button, which they do, but in different languages. The $form_state['input']['_triggering_element_value'] contains the text in Dutch, where $element['#value'] is in English. This causes Drupal to think that there is no triggering element for this form, so it takes the first button as the triggering element. The first button in the node_add form is the Save button, so Drupal will attach node saving submit handlers to the form resulting in an attempt to save a node in a place where this shouldn't happen.
I haven't figured out where/how admin_language does this, but disabling the module fixes the problem (or selecting English as your default admin language).
Comments
Comment #1
Koen.Pasman commentedI did some further digging and the underlying problem is that the media/ajax path is not registered as an administrative path.
Quickfix is by adding this selector to the administrative paths at admin/config/regional/language/admin_language -> media/ajax/*
Comment #2
Koen.Pasman commentedMoved this problem to the Media module, here: https://www.drupal.org/node/2401989
Comment #3
Koen.Pasman commented