This issue is basically backport of idea used in D7 (almost).
Background (and motivation)
In my simpletest test suite, I tried to test implementation of few theme function.
Theme implementation is in module, enabled in setUp method implementation.
When I tried to use theme in test case (ie,
$output = theme('my_theme_implementation', ...)
), it always returned NULL value. Theoretically, I can work around this problem (by using get and post requests with simpletest module API), but it makes tests bigger. I simple try to verify output from my theme implementation, not whole drupal stack behaviour, more in unit-like style.
Problem is in D6 implementation of theme() function:
<?php
function theme() {
$args = func_get_args();
$hook = array_shift($args);
static $hooks = NULL;
if (!isset($hooks)) {
init_theme();
$hooks = theme_get_registry();
}
?>
Using static variable leads to problem. This variable is $hooks is propagated once in whole request. If module is enabled after $hooks variable propagation, theme function will not be able to use themes implemented by this module. I took a look how this is implemented in D7, and I prepared patch, which should allow to enforce theme() function to use rebuilded theme registry.