summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
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;
}