Running Drupal 4.7.6
After upgrading from 4.7.x-2.1 to 4.7.x-3.0-rc1, and running update.php without error, went to administer > settings > flexicharge and got the following fatal error:

Fatal error: Cannot use string offset as an array in /hsphere/local/home/(redacted for privacy)/modules/system.module on line 748

Line 748 on my system module reads:

  $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );

Essentially adding the submit reset buttons to a form.
The warnings logged read:

    * warning: Missing argument 2 for system_settings_form(), called in /hsphere/local/home/(redacted for privacy)/modules/ecommerce/contrib/flexicharge/flexicharge.module on line 70 and defined in /hsphere/local/home/(redacted for privacy)/modules/system.module on line 747.
    * warning: htmlspecialchars() expects parameter 1 to be string, array given in /hsphere/local/home/(redacted for privacy)/includes/bootstrap.inc on line 609.

Which is this:

function flexicharge_settings() {

  $form = array();
  $form['flexicharge']['taxonomy'] = array(
    '#type' => 'checkbox',
    '#title' => t('debug mode (watchdog)'),
    '#description' => t('Please choose a category list to be used by flexicharge.'),
    '#default_value' => variable_get('eyedrop_debugging_mode', FALSE),
  );
  return system_settings_form($form);
}

Which I think needs to look like this:

function flexicharge_settings() {

  $form = array();
  $form['flexicharge']['taxonomy'] = array(
    '#type' => 'checkbox',
    '#title' => t('debug mode (watchdog)'),
    '#description' => t('Please choose a category list to be used by flexicharge.'),
    '#default_value' => variable_get('eyedrop_debugging_mode', FALSE),
  );
//Add the form ID
  return system_settings_form('flexicharge_settings', $form);
}

Comments

gordon’s picture

Status: Active » Fixed

Thanks this has now been fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)
Anonymous’s picture

Version: 4.7.x-3.0-rc1 » 5.x-3.0
Status: Closed (fixed) » Active

I got the exact same error updating to 3.0 from 2.1.

However, the fix mentioned above is already present in the code. Any ideas?

feliz’s picture

It is necessary to return the $form itself instead of the html generated by system_settings_form().
system_settings_form() is called on the form by system_site_settings() (system.module) after the flexicharge_settings() hook is called.

The code in flexicharge.module should look like:

function flexicharge_settings() {
  $form = array();
  $form['flexicharge']['taxonomy'] = array(
    '#type' => 'checkbox',
    '#title' => t('debug mode (watchdog)'),
    '#description' => t('Please choose a category list to be used by flexicharge.'),
    '#default_value' => variable_get('eyedrop_debugging_mode', FALSE),
  );
  return $form;
}
brmassa’s picture

Status: Active » Fixed

on EC4 the function doesnt exist anymore

Anonymous’s picture

Status: Fixed » Closed (fixed)