Commit 2035f1d4 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#194098 by mfer, theborg: reset theme in drupal_eval(), so the evaluated code...

#194098 by mfer, theborg: reset theme in drupal_eval(), so the evaluated code will not see the caller module as current theme
parent 4f38ed0b
......@@ -1499,10 +1499,29 @@ function drupal_map_assoc($array, $function = NULL) {
* output of the code.
*/
function drupal_eval($code) {
global $theme_path, $theme_info, $conf;
// Store current theme path.
$old_theme_path = $theme_path;
// Restore theme_path to the theme, as long as drupal_eval() executes,
// so code evaluted will not see the caller module as the current theme.
// If theme info is not initialized get the path from theme_default.
if (!isset($theme_info)) {
$theme_path = drupal_get_path('theme', $conf['theme_default']);
}
else {
$theme_path = dirname($theme_info->filename);
}
ob_start();
print eval('?>'. $code);
$output = ob_get_contents();
ob_end_clean();
// Recover original theme path.
$theme_path = $old_theme_path;
return $output;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment