• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item6825: RE error in Load.pm

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine Configure Low Closed   patch 5.1.1

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


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!


--- Load.pm   (revision 22272)
+++ Load.pm   (working copy)
@@ -109,7 +109,7 @@
         if (ref($_) eq 'HASH') {
         } 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 @@
 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;

-- 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". smile

-- 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, smile

-- TWiki:Main.PhillipHuang - 2011-12-16

Summary RE error in Load.pm
ReportedBy TWiki:Main.PhillipHuang
Codebase ~twiki4, 5.1.0
SVN Range TWiki-5.1.0, Mon, 12 Sep 2011, build 22279
AppliesTo Engine
Component Configure
Priority Low
CurrentState Closed

Checkins TWikirev:22452 TWikirev:22453
TargetRelease patch
ReleasedIn 5.1.1
Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2012-01-16 - GeorgeTrubisky
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback