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}".
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 1049208-format-variable-consistency-01.patch | 3.31 KB | soxofaan |
| geshifilter.php_error.patch | 626 bytes | manarth |
Comments
Comment #1
soxofaan commentedGood 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)
Comment #2
soxofaan commentedI 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
Comment #3
boombatower commentedComment #4
yukare commentedSince the bug is fixed, i will close this issue.