Hook theme registry alter issue takes away entire site theme
The entire theme disappearing issue has an identified culprit.
(It was sort of cute– devel still printed the query log, but that's all we got for each page.)
First I commented out scf.module's implementation of hook_theme(), but visiting the admin/build/modules and admin/build/themes pages didn't bring it back.
Then I commented out the implementation of hook_theme_registry_alter(), and that brought the site back (and with it, the ability to see the warning messages).
First, the guilty function, that appears to only work with the scf stub theme:
<?php
/**
* Implementation of hook_theme_registry_alter().
*/
function scf_theme_registry_alter(&$theme_registry) {
// names of hooks handled by scf
$theme_hooks = array(
'block',
'comment',
'comment_wrapper',
'node',
'forums',
'forum_list',
'forum_topic_list',
'forum_icon',
'forum_submitted',
// 'forum_topic_navigation' (not currently handled)
'page',
);
// Get the path to this module
$path = drupal_get_path('module', 'scf') . '/theme';
// Add the path paths
foreach ($theme_hooks AS $theme_hook) {
if (!scf_au_stringpart_in_array($theme_registry[$theme_hook]['theme paths'],
'themes')) {
// if there is no path with 'themes' in the theme registry
// then replace the template path with our module path
// if we add this when the theme is in charge, it throws errors
// that oddly mungle the theme path plus the module template path
// but without a theme directory being called first, this works
// and this really is necessary for everything above
// This just gets crazier and crazier. Must be wrong, but it works.
// Transform _ in hook to - to match template naming scheme
$tpl = strtr($theme_hook, '_', '-');
$theme_registry[$theme_hook]['template'] = $path . '/' . $tpl;
}
array_unshift($theme_registry[$theme_hook]['theme paths'], $path);
// setting the specific chosen path isn't necessary
// $theme_registry[$theme_hook]['theme path'] = $path . '/' . $theme_hook;
// this isn't documented, but it has proven necessary for page at least
}
}
?>
And now the error message:
* warning: include(./themes/garland/profiles/scf/modules/scf/theme/page.tpl.php) [function.include]: failed to open stream: No such file or directory in /RCS/agaric/agaric-sites/scf/includes/theme.inc on line 979.
* warning: include() [function.include]: Failed opening './themes/garland/profiles/scf/modules/scf/theme/page.tpl.php' for inclusion (include_path='.:/Applications/xampp/xamppfiles/lib/php') in /RCS/agaric/agaric-sites/scf/includes/theme.inc on line 979.
Returning (and moving and focusing) my commented out code seems to have fixed it.
<?php
/**
* Implementation of hook_theme_registry_alter().
*/
function scf_theme_registry_alter(&$theme_registry) {
// names of hooks handled by scf
$theme_hooks = array(
'block',
'comment',
'comment_wrapper',
'node',
'forums',
'forum_list',
'forum_topic_list',
'forum_icon',
'forum_submitted',
// 'forum_topic_navigation' (not currently handled)
'page',
);
// Get the path to this module
$path = drupal_get_path('module', 'scf') . '/theme';
// Add the path paths
foreach ($theme_hooks AS $theme_hook) {
if (!scf_au_stringpart_in_array($theme_registry[$theme_hook]['theme paths'],
'themes')) {
// if there is no path with 'themes' in the theme registry
// then replace the template path with our module path
// if we add this when the theme is in charge, it throws errors
// that oddly mungle the theme path plus the module template path
// but without a theme directory being called first, this works
// and this really is necessary for everything above
// This just gets crazier and crazier. Must be wrong, but it works.
// Transform _ in hook to - to match template naming scheme
$tpl = strtr($theme_hook, '_', '-');
$theme_registry[$theme_hook]['template'] = $path . '/' . $tpl;
}
array_unshift($theme_registry[$theme_hook]['theme paths'], $path);
// setting the specific chosen path isn't necessary
}
$theme_registry[$theme_hook]['theme path'] = $path . '/' . 'page'; // $theme_hook;
// this isn't documented, but it has proven necessary for page at least
}
?>
Comments
Post new comment