Multilang filter

Revision as of 22:55, 27 March 2006 by Robert Brenstein (talk | contribs)

Jump to: navigation, search

Currently the multilang filter breaks the cache system. The "lang" concept should be included in the mechanism to be able to cache contents when such filter is enabled.

Written by Robert Brenstein:

I am not a proper Moodle developer, so I may be missing something very obvious, but since I was forced to occupy myself with functioning of format_text() function, I have prondered the problem of caching multilang strings.

My interpretation of current setup is that multilang disables caching because the md5 key used by in the format_text() to identify cached entries is based on the text of cached items. In the case of filtered items, the text is changed by the filter called in the middle of format_text(), so the correct key cannot be ascerned upon entry to format_text(), that is before the text was processed by the filter. Catch 22 so to speak.

An approach to change this could be:

First, add language code to md5 key calculation in addition to all the $option parms that were recently added.

Second, base md5 key not on the filtered text but on the original text passed to format_text() function.

These two combined should provide unique key values and catch all text and language changes.

In case dual behavior need to be maintained, for example to bypass caching when another filter is called as well as to avoid any unexpected side-effects of this change, an extra parameter to format_text() function can be added, initialized as default to NULL, for example, so if it is NULL, the current behavior remains in effect. It would be then up to the caller to activate alternative behavior (more than one could actually be possible).