summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-12-16 14:09:24 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-12-16 14:09:24 +0000
commit2035f1d48f24ade399657cc04116492241553ee3 (patch)
treea29d3d7ec4c9a09d32198deb5050e6ae87a3a86b /includes
parent4f38ed0b29e86242ce0aee64f9ccab02e8c243d7 (diff)
downloadbrdo-2035f1d48f24ade399657cc04116492241553ee3.tar.gz
brdo-2035f1d48f24ade399657cc04116492241553ee3.tar.bz2
#194098 by mfer, theborg: reset theme in drupal_eval(), so the evaluated code will not see the caller module as current theme
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc19
1 files changed, 19 insertions, 0 deletions
diff --git a/includes/common.inc b/includes/common.inc
index fdf7dc2f0..c2b1d5914 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -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;
}