Problem/Motivation

When I try to update the value of a managed_file field as a multilingual variable in a custom form, I get the following error :
Fatal error: Call to undefined function variable_realm_variable_settings_form_submit() in /Users/villette/Sites/foo/includes/form.inc on line 1460
I declared this variable with hook_variable_info().

Proposed resolution

Instead of using module_load_include() in the function variable_realm_variable_settings_form_alter() (in variable_realm.variable.inc), the function form_load_include() should be used.

Comments

villette’s picture

I think this patch should do the trick

mavaddat’s picture

I can confirm that this fixes the problem. Thank you villette!

iva2k’s picture

Title: A managed_file field causes problem when used as a multilingual variable » Multilingual variables cause critical error when form is saved (e.g. managed_file field when used as a multilingual variable)
Priority: Normal » Major
Status: Active » Reviewed & tested by the community

I stumbled upon this problem in a different module (settings page with multilingual variables) and patch in #1 solves the issue.
form_load_include() is a fairly recent drupal 7 addition and all form-related (i.e. submit, validate) functions contained in non .module files need to be loaded using form_load_include().
RTBC.

Also I did a quick code review, and found module_load_include('form.inc', ...) in few places where it most likely also need to be changed to form_load_include():

file variable.module: functions variable_edit_form(), variable_edit_subform()

file node.variable.inc: function node_variable_type_subform()

file variable_admin.inc: function variable_admin_realm_edit()

file variable_realm.module: function variable_realm_form_system_theme_settings_alter()

I have no test cases to verify if it breaks anything, but I'm pretty sure it will find ways to screw things up in unexpected ways. Maintainers, please review code in those and make corrections as needed.

iva2k’s picture

StatusFileSize
new2.28 KB

Here's a patch including other locations that should be changed to form_load_include() for sure.

Someone from maintainers need to review code in other places mentioned in #6:

  • file variable.module: function variable_edit_subform()
  • file node.variable.inc: function node_variable_type_subform()
  • file variable_admin.inc: function variable_admin_realm_edit()
HydroZ’s picture

This patch solved it for me. I applied it to Version 7.x-2.2 an it works as well.

tengoku’s picture

Version: 7.x-2.1 » 7.x-2.2

I'm reporting that this patch also works for me on 7.x-2.2, updating the issue to this version. thanks

Anticosti’s picture

#4 worked for me too.
Much appreciated. Thanks!

jomarocas’s picture

hey this work fine, this solutions of the bug

bforchhammer’s picture

Title: Multilingual variables cause critical error when form is saved (e.g. managed_file field when used as a multilingual variable) » Call to undefined function error when form is saved (e.g. managed_file field when used as a multilingual variable)
Version: 7.x-2.2 » 7.x-2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed #4. Thanks for patch and reviews!

Status: Fixed » Closed (fixed)

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

lmeurs’s picture

Thanks!

pratik60’s picture

Issue summary: View changes

After trying to save a variable with managed file, I get this bug.

Call to undefined function variable_form_submit_callback() in /webapps/d7/includes/form.inc on line 1513

Are we sure this is fixed or am I missing something?

$type['embed_form_file_path'] = array(
    'title' => t('File path'),
    'element' => array(
      '#type' => 'managed_file',
    ),
    'localize' => TRUE,
  );
lykyd’s picture

I'm experiencing this error with Variable 7.x-2.5 and Variable File 7.x-1.x-dev, that implement the patch #4.

I'm implementing variables in a hook_variable_info().

Using a "file_upload" type won't give any error, but changing it to "file_managed" gives me a white screen with the error :
PHP Fatal error: Call to undefined function variable_form_submit_callback() in /www/mysite.fr/site/includes/form.inc on line 1520, referer: http://mysite.local/admin/mysite/settings

Setting the localize parameter to false does fix the issue but prevent me from having two different files for each language.

$variable['myvariable_activity_file'] = array(
      'type'              => 'file_managed',
      'title'             => t('File', array(), $options),
      'upload_location'   => 'public://settings_files',
      'localize' => true,
      'group' => 'settings',
    );
geek-merlin’s picture

#12, #13: YES this zombie returned from its grave. Exorcising it in #2918293: Call to undefined funtion when form is saved (eg managed file).