Hi
I'm working on a patch for geshifilter (I haven't created an issue for it yet but will shortly). In the process of doing this, I ran into some unexpected behavior in my patch. My patch calls _geshifilter_get_tags but doesn't seem to be getting the right values returned.
For example, I have 2 input formats, filtered HTML and unfiltered HTML. For both of those filters geshifilter is enabled. At admin/settings/geshifilter I have checked "Seperate settings per input format".
The relevant settings for the two input formats as displayed in the config web based GUI are as follows:
Filtered HTML:
Generic syntax highlighting tags: cpp ccode code
per language tags:
c-->ccode
c++-->cpp
css-->html
Unfiltered HTML:
Generic syntax highlighting tags:
per language tags:
c-->ccode
c++-->cpp
html4strict-->html
Note that the language that the "html" language code is attached to is different. I realize that these assignments are sort of nonsense, but they are what I had.
Now, if I edit _geshifilter_get_tags and add the following line just before the return statement:
print_r($geshifilter_tags_cache);
and if I call _geshifilter_get_tags from the patch I'm working on, I get this output:
Array
(
[0] => Array
(
[0] => cpp
[1] => ccode
[2] => code
)
[1] => Array
(
[0] => ccode
[1] => cpp
[2] => html
)
[2] => Array
(
[ccode] => c
[cpp] => cpp
[html] => css
)
)
Array
(
[0] => Array
(
[0] => cpp
[1] => ccode
[2] => code
)
[1] => Array
(
[0] => ccode
[1] => cpp
[2] => html
)
[2] => Array
(
[ccode] => c
[cpp] => cpp
[html] => css
)
)
This doesn't look right to me, as both input formats are giving the same values for the tags used.
If I modify _geshifilter_get_tags (to remove the static variable) so it looks like this:
function _geshifilter_get_tags($format) {
// static $geshifilter_tags_cache = NULL;
// if ($geshifilter_tags_cache === NULL) {
$generic_code_tags = _geshifilter_tag_split(geshifilter_tags($format));
$language_tags = array();
$tag_to_lang = array();
$enabled_languages = _geshifilter_get_enabled_languages();
foreach ($enabled_languages as $language => $fullname) {
$lang_tags = _geshifilter_tag_split(geshifilter_language_tags($language, $format));
foreach ($lang_tags as $lang_tag) {
$language_tags[] = $lang_tag;
$tag_to_lang[$lang_tag] = $language;
}
}
$geshifilter_tags_cache = array($generic_code_tags, $language_tags, $tag_to_lang);
// }
print_r($geshifilter_tags_cache);
return $geshifilter_tags_cache;
}
and then I reload the same page and look at what is printed, I get this (which appears to be correct):
Array
(
[0] => Array
(
[0] => cpp
[1] => ccode
[2] => code
)
[1] => Array
(
[0] => ccode
[1] => cpp
[2] => html
)
[2] => Array
(
[ccode] => c
[cpp] => cpp
[html] => css
)
)
Array
(
[0] => Array
(
)
[1] => Array
(
[0] => ccode
[1] => cpp
[2] => html
)
[2] => Array
(
[ccode] => c
[cpp] => cpp
[html] => html4strict
)
)
I'm pretty sure that the patch I'm working on has nothing to do with this, since all of that code is in the function geshifilter_admin_filter_conflicts(). Can you take a look at this and either try to fix _geshifilter_get_tags so that it returns the right values or explain to me what's going on with the code and where my thinking has gone wrong.
BTW, I tried clicking the link on the help page to clear the cache (/drupal/geshifilter/clearfiltercache?destination=admin%2Fhelp%2Fgeshifilter) and that didn't change anything.
Comments
Comment #1
soxofaan commentedShould be solved by http://drupal.org/cvs?commit=85252
The caching in _geshifilter_get_tags() indeed did not take the different input formats into account
thanks for testing and bug reporting
that callback clears only the filter cache, which is the cache that holds filtered (node) content. It has nothing to do with caching in _geshifilter_get_tags() and other functions
Comment #2
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.