In _theme_build_registry, the first time a registry is built, all of the module theme hooks are run and cached, in the theory that this won't change by theme, and so the same information can be used when the registry is built for a different theme on the same site. However, this is flawed - _theme_process_registry is what fetches the preprocess functions in the themes, and so if theme1 has a preprocess function for a module-declared theme function, and then theme 2 is active when the site is being accessed after the cache is cleared, then when theme1's registry is built later, it doesn't have the information for this theme function.
An example will maybe work better. We'll have the theme function foobar, declared in module example, and then themes alpha and beta. Theme alpha declares alpha_preprocess_foobar(), theme beta does not. When the cache is cleared, and the first access of the site is through theme beta, then _theme_build_registry finds the theme_foobar function in the example module, looks for any preprocess functions (in theme beta, the active theme), fails to find them, and this is what gets written to the cache at 'theme_registry:build:modules'.
When the site is visited by someone using the alpha theme, then _theme_build_registry starts up, sees that there's module theme data in 'theme_registry:build:modules', and uses that instead of going through all of the module theme data again. However, that means that the function alpha_preprocess_foobar() is never discovered by the theme registry, and the pages look where where theme_foobar is used.
I can see that 'theme_registry:build:modules' is being used to try and speed up the registry, but I don't think that's valid to do anymore given this problem - the registry doesn't get rebuilt that often for each theme, after all, and it's causing problems with preprocess functions in themes.
Comments
Comment #1
simeI am experiencing this very issue. Seems odd that this problem isn't more common... I should note that if people are using Overlay, then they won't see this issue, because I think they'll technically be on the front-end theme.
So, I am overriding the search block in the front-end theme: MYTHEME_preprocess_search_block_form()
If I clear the cache with admin/config/development/performance with the Seven theme and no Overlay, then go to the front end, and preprocess hasn't kicked in. (Dumping the registry shows it's not been recognised.) I fix the problem by clearing the cache, say with admin_menu, on the front-end.
Comment #2
sun