When you navigate to /admin/config/changes/formats/xxx (where xxx is the name of an input format), the settings callback provided by hook_filter_info() is invoked.

Geshifilter's is:

function geshifilter_filter_settings_callback($form, &$form_state, $filter, $format, $defaults, $filters) {
  require_once drupal_get_path('module', 'geshifilter') .'/geshifilter.admin.inc';
  return _geshifilter_filter_settings($form, $form_state, $filter, $format, $defaults, $filters);
}

The $format variable is an object with standard properties. $format->format represents the machine name of the format.

This variable is passed to a helper to fetch geshifilter settings, which calls a helper, which calls another helper...which eventually calls variable_get using the machine name of the format:

function _geshifilter_filter_settings($form, &$form_state, $filter, $format, $defaults, $filters) {
  ...
  $settings['general_tags'] = _geshifilter_general_highlight_tags_settings($format);



function _geshifilter_general_highlight_tags_settings($format = NULL) {
  ...
  '#default_value' => _geshifilter_tag_styles($format),



function _geshifilter_tag_styles($format = NULL) {
  ...
  return variable_get("geshifilter_tag_styles_{$format}", _geshifilter_tag_styles());

Throughout, $format is an object, so variable_get("geshifilter_tag_styles_{$format}" will fail.
The attached patch invokes the helpers with $passed_format instead (which is the machine name of the format).

An alternative approach might be to simply change the variable_get to variable_get("geshifilter_tag_styles_{$format->format}".

Comments

soxofaan’s picture

Status: Active » Needs work
StatusFileSize
new3.31 KB

Good catch.

there is indeed a problem with the $format variable, which has "gained" ambiguity in Drupal 7 (sometimes it's a string, sometimes it's an object).

The patch solves it, but we'd better document all the functions in GeSHi filter what they expect (a string or an object).

Started to document them (see attached patch)

soxofaan’s picture

Category: bug » task

I decided to already commit the bug fix: http://drupal.org/cvs?commit=493826

still to do: document all the functions that accept a $format argument better

boombatower’s picture

Status: Needs work » Active
yukare’s picture

Status: Active » Fixed

Since the bug is fixed, i will close this issue.

Status: Fixed » Closed (fixed)

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