evaluate_cmsimple_scripting() is a real hack, because it has to evaluate arbitrary PHP code inside a function as if that code would be evaluated in the global scope.
At least the following simplification should be possible without any side-effects. Replace:
Code: Select all
global $output;
foreach ($GLOBALS as $__name => $__dummy) {
$$__name = &$GLOBALS[$__name];
}
Code: Select all
extract($GLOBALS, EXTR_REFS);
We have to double-check that this change wouldn't break anything (at least it passes the current unit-tests), and if so, I suggest to make this change for CMSimple_XH 1.6.3.
However, I would like to get rid of the following code also:
Code: Select all
$__scope_before = array_keys(get_defined_vars());
eval($__script);
$__scope_after = array_keys(get_defined_vars());
$__diff = array_diff($__scope_after, $__scope_before);
foreach ($__diff as $__var) {
$GLOBALS[$__var] = $$__var;
}
This code is there to promote any newly defined variables to the global scope. I assume it is mainly necessary for $keywords and $description. I'm not even sure if it makes sense to allow these variables to be set by CMSimple scripting (meta_tags offers a much nicer solution), but we could easily cater for these variables:
Code: Select all
global $keywords, $description;
extract($GLOBALS, EXTR_REFS);
We should consider doing this simplification for CMSimple_XH 1.7/2.0. Even if it might break a few sites, the simplification of evaluate_cmsimple_scripting() is worth it.
Christoph