RE error in 'line 112' of 'twiki/lib/TWiki/Configure/Load.pm', as you can see:
s/(\$TWiki::cfg{
[[A-Za-z0-9{}
]+})/eval $1||'undef'/ge;
There're three brackets, I think it would be:
s/(\$TWiki::cfg{
[A-Za-z0-9{}
]+})/eval $1||'undef'/ge;
--
TWiki:Main.PhillipHuang
- 2011-12-14
Thanks! Confirmed, needs to be fixed.
--
TWiki:Main.PeterThoeny
- 2011-12-14
This is now fixed in svn trunk and TWiki-5.1 branch. Thanks Phillip!
Changes:
--- Load.pm (revision 22272)
+++ Load.pm (working copy)
@@ -109,7 +109,7 @@
if (ref($_) eq 'HASH') {
expand(\%$_);
} else {
- s/(\$TWiki::cfg{[[A-Za-z0-9{}]+})/eval $1||'undef'/ge;
+ s/(\$TWiki::cfg{[A-Za-z0-9{}]+})/eval $1||'undef'/ge;
}
}
}
@@ -129,7 +129,7 @@
=cut
sub expandValue {
- $_[0] =~ s/(\$TWiki::cfg{[[A-Za-z0-9{}]+})/eval $1||'undef'/ge;
+ $_[0] =~ s/(\$TWiki::cfg{[A-Za-z0-9{}]+})/eval $1||'undef'/ge;
}
=pod
--
TWiki:Main.PeterThoeny
- 2011-12-14
Line ' s/(\$TWiki::cfg{[A-Za-z0-9{}]+})/eval $1||'undef'/ge;' is seemed to expand $TWiki::cfg{}{}deeply, I think it does not need 'undef' because replace only take effect when find $1, in another word, $1 is always existing when matched. Perhaps would remove undef and using '' s/(\$TWiki::cfg{[A-Za-z0-9{}]+})/$1/ge;"
--
TWiki:Main.PhillipHuang
- 2011-12-15
Probably could do that. A change like this needs to be tested carefully. It works now, "if it is not broken, don't fix it".
--
TWiki:Main.PeterThoeny
- 2011-12-14
Actually, the eval is needed. Take this example:
$TWiki::cfg{DataDir} = '/var/www/twiki/data'
$TWiki::cfg{DebugFileName} = '$TWiki::cfg{DataDir}/debug.txt';
The second variable contains a variable embedded in the value. It needs to be expanded, so that as a result we have
$TWiki::cfg{DebugFileName} = '/var/www/twiki/data/debug.txt';
So, the regular expression (the one fixed) looks for
$TWiki::cfg{...}
patterns and evaluates them. The eval will fail in case the variable does not exist. For this case we have the
'undef'
.
--
TWiki:Main.PeterThoeny
- 2011-12-14
I see. Thanks Peter,
--
TWiki:Main.PhillipHuang
- 2011-12-16