Item11136: Spurrious config item changes reported if key contains a colon

pencil
Priority: Urgent
Current State: Closed
Released In: 1.1.4
Target Release: patch
Applies To: Engine
Component: Configure, JQueryPlugin
Branches:
Reported By: TimotheLitt
Waiting For: Main.CrawfordCurrie
Last Change By: DavidMasterson
Every time I do a Save in configure, I get told that three config items that I've never touched have changed:

If I simply enter Configure and do a save, I get:

You are about to update 3 settings 
{JQueryPlugin}{Plugins}  
{JQueryPlugin}{Plugins}{Validate}{Enabled} 1 
{JQueryPlugin}{Plugins}{WikiWord}{Enabled} 1 

Go back in your browser if you want to make any changes.

If I save, I get the same list as "your updates". Then, if I immediately click save again - I get the same report.

I don't understand why the first item appears at all - it should be simply a hashref! The others do appear set under extensions:JQueryPlugin; I could imagine that perhaps configure turned them on to support the spiffy new GUI - but (a) on is the default (which I haven't messed with) and (b) after saving once, the change indication shouldn't be happening again.

Something fishy...

This is trunk, updated as of last night.

-- TimotheLitt - 18 Sep 2011

Confirmed, but it seems to be worse that the spurious updates. The issue is caused by the double-colon in some of the plugin names. $Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Autocomplete}{Enabled} = 1; It also seems to break the detection of default settings for the JQuery plugins. A test changing the :: to xx in the JQueryPlugin Config.spec file seems to confirm the cause.

Also noticed that there are some comments out of place in the plugins list in JQueryPlugin config.spec file.

-- GeorgeClark - 19 Sep 2011

That makes sense - it just felt wrong. I need to update the TaskDaemon's config item parser too. It might be a good idea to have a global variable with a standard REGEX for config items. I'm (now) using
our $configItemRegex = qr/(?:\{[-:\w'"]+\})+/o;

-- TimotheLitt - 19 Sep 2011

Your other problem seems to be that the spec file has hash keys containing :: that are unquoted. This is invalid perl syntax e.g.:
# perl -Mstrict -Mwarnings -e'my %x; $x{a::b} = 1;'
Bareword "a::b" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.
# perl -Mstrict -Mwarnings -e'my %x; $x{"a::b"} = 1;'
#
Here is the patch for that:
Index: JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Config.spec
===================================================================
--- JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Config.spec   (revision 12579)
+++ JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Config.spec   (working copy)
@@ -191,34 +191,34 @@
 $Foswiki::cfg{JQueryPlugin}{Plugins}{UI}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Autocomplete}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Autocomplete'}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Resizable}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Resizable'}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Draggable}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Draggable'}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Accordion}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Accordion'}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Tabs}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Tabs'}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Slider}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Slider'}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Dialog}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Dialog'}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Button}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Button'}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Datepicker}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Datepicker'}{Enabled} = 1;

 # **BOOLEAN**
-$Foswiki::cfg{JQueryPlugin}{Plugins}{UI::Progressbar}{Enabled} = 1;
+$Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Progressbar'}{Enabled} = 1;

 # **BOOLEAN**
 $Foswiki::cfg{JQueryPlugin}{Plugins}{Validate}{Enabled} = 1;

(Aren't warning/strict enabled when the .spec file is read as a default? They should be.)

You may want to check point of use as well.

-- TimotheLitt - 19 Sep 2011

Timothe - the error was not being caught because it was in an eval of a constructed assignment statement down in Valuer.pm. I think that Crawford reached the conclusion that the better fix is to not support colon in the config keys. Quoting the key just pushes the problems to elsewhere in the code.

-- GeorgeClark - 20 Sep 2011

Shouldn't push too far. Note that the quotes (and '-') are in the regex due to the fact that languages already require quoted (non-bareword) keys - and that goes back to TWiki. Once any quoted key is supported, it shouldn't matter what's in the quotes or how often they appear...so I don't see the problem with adding ':' to the regex if it makes life easier for JQuery.

See Foswiki.spec:
$Foswiki::cfg{Languages}{'zh-cn'}{Enabled} = 1;
$Foswiki::cfg{Languages}{'zh-tw'}{Enabled} = 1;

W.r.t. Valuer - I have several similar evals in the task daemon - however, I do check $@, which Valuer should do in any case.

-- TimotheLitt - 20 Sep 2011

Good point about quoted params. I tested again and now they seem to be working okay for JQuery. Not sure why the failed when I tested before. Also added a "die" to configure for illegal values. Probably a bit draconian, but we should not be running into these errors.

Note that if LocalSite.cfg has been updated with the non-quoted UI:: keys, then they will need to be manually cleaned up.

-- GeorgeClark - 26 Sep 2011

Marked waiting for release for both 1.1.4 and trunk. The error was triggered by changes to JQueryPlugin not yet released for 1.1.4.

-- GeorgeClark - 26 Sep 2011

Thanks for pursuing this. Adding the die seems OK (not draconian) to me - it will only happen if a spec file is updated with something bad, and anyone who does that can cope with a die. Much better than the silent failure that started this.

  • When looking at the changesets, I got an intermittent error from trac with a long traceback, but this is the key report: "TimeoutError: Unable to get database connection within 0 seconds. (OperationalError('FATAL:  connection limit exceeded for non-superusers\n',))" I've seen this several times in the past few days - suspect there's an anti-abuse timer that's too sensitive.
  • FWIW, I decided to future-proof the task daemon's regex for config item keys by replacing it with the following regex - you could consider doing the same in Valuer. It looks for a list of braces containing a bareword, a single-quoted string or a double-quoted string, allowing for backslashing in the quoted strings and whitespace just inside the braces. That would prevent adding other special characters to the existing regex one-by-one as future creativity trips over this... It also won't accept illegal keywords (like the :: outside of quotes).
        our $configItemRegex = qr/(?:\{\s*(?:\w+|'(?:\\.|[^'])*'|"(?:\\.|[^"])*")\s*\})+/o;
  • Extra credit: if someone were ambitious, _parse in FoswikiCfg.pm could also use this regexp to validate the keys as they're read from the .spec, which would catch this kind of error a lot closer to the source. E.g. something like adding these two lines should do it:
   253          elsif ( $l =~ /^#?\s*\$(?:(?:Fosw|TW)iki::)?cfg([^=\s]*)\s*=(.*)$/ ) {
   254
   255              # $Foswiki::cfg{Rice}{Brown} =
   256              my $keys         = $1;
   257              my $tentativeVal = $2;
   +++              $keys =~ /^$configItemRegex$/o or
   +++                  die "Invalid configuration item key '$keys' in $file at line $. - must be a valid literal hash element reference\n>>> $l\n"; # $ letter l, not number 1

-- TimotheLitt - 26 Sep 2011

Timothe, Good suggestions, thanks. You should request commit permission so you can contribute these thing directly. Trac btw is a server issue that has not been tracked down.

Crawford - can you review these? Makes sense to me.

-- GeorgeClark - 27 Sep 2011

Tried upgrading to 4.34 of JQueryPlugin in Foswiki v1.1.5 with configure. I think the upgrade worked, but configure still reports v4.33. I updated to the latest version of Valuer.pm and tried the upgrade again. No change.

-- DavidMasterson - 01 Jun 2012
 

ItemTemplate edit

Summary Spurrious config item changes reported if key contains a colon
ReportedBy TimotheLitt
Codebase 1.1.3, trunk
SVN Range
AppliesTo Engine
Component Configure, JQueryPlugin
Priority Urgent
CurrentState Closed
WaitingFor CrawfordCurrie
Checkins distro:5c444f7c643b distro:e13c6ff169b7 Rev 12579 not found distro:db3b7924329c distro:bdf178cb0fb8 distro:257aeeac088d distro:9158924cb7ac
TargetRelease patch
ReleasedIn 1.1.4
CheckinsOnBranches
trunkCheckins
Release01x01Checkins
Topic revision: r20 - 01 Jun 2012, DavidMasterson
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy