You are here: Foswiki>Tasks Web>Item13220 (04 Mar 2015, GeorgeClark)Edit Attach

Item13220: undefok NUMBERs generate a Number format error on an undef value

pencil
Priority: Urgent
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: Configure, ConfigurePlugin
Branches: master
Reported By: MichaelDaum
Waiting For:
Last Change By: GeorgeClark
This ...

# **NUMBER LABEL="Maximum Requests" CHECK="undefok"**
# This is the maximum number of requests a backend is allowed to serve. Afterwards it will be killed and replaced
# with a new one. Set to -1 to disable this check.
$Foswiki::cfg{FastCGIContrib}{MaxRequests} = 100;

... generates a "Number format error" on an undef value as it seems.

-- MichaelDaum - 19 Jan 2015

Similarly URL with an undefok seems to return a scheme error. See {PROXY}{Host} which has got an undef default which then is flagged as an error.

-- MichaelDaum - 19 Jan 2015

FastCGIContrib doesn't appear to have a Config.spec so I'm not sure what state it's in. I tried adding undefok to {MinPasswordLength} and it works exactly as expected.

{PROXY}{HOST} is a URL and is undefok with no problems.

Can you be more specific?

-- CrawfordCurrie - 20 Jan 2015

Try this one https://github.com/foswiki/FastCGIEngineContrib/blob/Item13010/lib/Foswiki/Contrib/FastCGIEngineContrib/Config.spec

And when I click on "reset" at {PROXY}{HOST} I get this:

ConfigureSnap4.png

Of course undef doesn't start with http:// ... but hey it isn't supposed to wink

-- MichaelDaum - 20 Jan 2015

Hm... Actually "undef" is set by unchecking the enable checkbox. The "default" button is aplying the literal "undef" to a defined field.

There is currently a serious issue with default handling. I've tried to fix it but I'm not getting anywhere. Defaults are getting "quoted" (Causes the REGEX and STRING unit tests to fail). and with this example, the default is undefined, so applying the default should uncheck the enable box, causing the setting to be undef.

I'm not sure that "enable" is the best term to use for that checkbox. "defined' is probably more accurate, but seems too geeky.

-- GeorgeClark - 21 Jan 2015

Agreed, there's no bug here. I leave it up to you what to call the checkbox ("no value" works for me i.e inverting the sense).

-- CrawfordCurrie - 21 Jan 2015

Well there is an error, even the unit tests indicate so: when the value is undef and the item is "undefok" why would undef then be a number error?

ConfigureSnap5.png

-- MichaelDaum - 21 Jan 2015

Agreed, there is a bug. It's urgent. Applying default values is broken for many fields.
  • PubUrlPath: Default is a quoted '/bin/../pub' Reports: Path ('/foswiki/pub') is not valid
  • CookieRealm: Default becomes '' ... not an empty field
  • {Session}{filePermission} Gets converted to decimal: Error: Value must be no greater than 777
  • AccessibleCfg: Restore default Errors with Must be an array

it's broken all over the place.

-- GeorgeClark - 21 Jan 2015

All over the place? Can you be more specific? I fixed the STRING cases but there may be others I don't know about.

-- CrawfordCurrie - 22 Jan 2015

Okay. At the time, since the majority of the fields are STRING, "all over the place" was pretty literal. Running through clicking reset here and there:

  • {TemplatePath}. Default button sets it to unbalanced quotes. Starts with quote, but no end quote. After saving config, foswiki fails with "Unable to do LocalSite.cfg"
  • {RememberChangesFor} Default is literal "31 * 24 * 60 * 60" which generates an error.
  • {Store}{dirPermission} Default is decimal 1373 and is saved as 755 (decimal) not 493 (decimal equivalent of octal 0755). So OCTAL types are broken.
  • {FormTypes} Fails with "Was expecting this to be an array"

Basically I'm just randomly hitting "Default" button when it's there, though it probably should not be there for most of these as they are already set to the default.

It looks like {FormTypes} also demonstrates some sort of error with PERL types.
  • The field has no formatting initally in my LSC.
  • Clicking "default" button formats it nicely in the UI
  • But... it now fails validation. (Needs to be "eval'd" before checking?)
  • Save correctly saves the formatted field, LSC retains the formatting.
  • But refreshing configure, and the formatting is lost from the UI again.

-- GeorgeClark - 24 Jan 2015

Also... just ran bootstrap on a new install.

  • {DefaultUrlHost} was written into LocalSite.cfg without quotes.
  • {Password} also written unquoted.

And after running the email autoconfigure wizard, the userid, password, mailhost and webmaster email were all unquoted

-- GeorgeClark - 24 Jan 2015

Another thing I'm seeing is a large number of undefined errors.

[Sat Jan 24 10:48:22 2015] jsonrpc: Use of uninitialized value in string at (eval 692) line 1.
[Sat Jan 24 10:48:22 2015] jsonrpc: Use of uninitialized value in string at (eval 693) line 1.
[Sat Jan 24 10:48:22 2015] jsonrpc: Use of uninitialized value in string at (eval 694) line 1.
[Sat Jan 24 10:48:22 2015] jsonrpc: Use of uninitialized value in string at (eval 695) line 1.
...   (many dozens occur)

Oh... and another unquoted ... after mail wizard, the MailMethod Net::SMPT (STARTTLS) is unquoted and causes a later error.

-- GeorgeClark - 24 Jan 2015

Sorry, have to reopen this one as it obviously is not fixed. Try to rest {PROXY}{HOST} ... same error message as in above screenshot.

None of the defaults should generate a validation error.

More quirks going thru all items hitting reset:

  • ForceDefaultUrlHost does not disable the boolean flag even though $FALSE is the default. - FIXED
  • UseLocale same ... $FALSE is the default however hitting reset wont disable to checkbox - FIXED
  • {Store}{overrideUmask} same - FIXED
  • {Cache}{Enabled} same - FIXED
  • {MergeHeadAndScriptZones} same - FIXED
  • PermittedRedirectHostUrls defaults to '' ... should default to the empty string - FIXED
  • ScriptDir defaults to '/home/httpd/foswiki/bin' ... should default to /home/httpd/foswiki/bin without quotes - FIXED
  • PubDir same - FIXED
  • DataDir same - FIXED
  • any other ...Dir have single quotes in the defaults ... which should probably not be the case - FIXED
  • SafeEnvPATH default is undef ... which generates warning message "undef could not be found" - FIXED
  • AuthScripts generates an error saying "Cannot open {ScriptDir} '/home/httpd/foswiki/bin' for read (No such file or directory)" - FIXED
  • AccessibleCFG hitting reset generates an error "Must be an array" ... which it is - FIXED
  • {Log}{Implementation} should default to PlainFile ... not none - FIXED
  • {Log}{Dir} hitting reset generates an error "'/home/www-data/vhosts/localhost/working/logs' does not exist, and I can't create it: No such file or directory" ... this directory definitely does exist once the quotes are removed - FIXED
  • {Store}{Implementation} hitting reset wont set it to the default on Foswiki.spec - FIXED
  • {Store}{SearchAlgorithm} same ... defaults to forking but once you switched to pure perl it won't reset back to forking - FIXED
  • {Store}{EgrepCmd} ... hitting reset adds single quotes - FIXED
  • {Store}{FgrepCmd} same - FIXED
  • {MailProgram} reset adds single quotes - FIXED

  • lots of javascript errors in configure.js while navigating thru tabs "Uncaught SyntaxError: Unexpected token F". As a consequence some tabs won't show up on first click. Selecting another and coming back will finally load the tab ... - I don't see these errors when using Chrome. They sound like eval errors when parsing JSON responses
  • clicking "auto-configure email" shows an error in the dialog popping up: Can't load pluggable SCRIPTHASH: Attempt to reload Foswiki/Configure/Pluggables/SCRIPTHASH.pm aborted. Compilation failed in require at (eval 68340) line 1, <$fh> line 130. {SMTP}{MAILHOST} is not defined, so cannot use SMTP. Falling back to mail program" ... {SMTP}{MAILHOST} is definitely defined not looked into
    • I had to disable FindBin to make it work under fcgi + virtualhosting (patch below) - MD
  • {WebMasterEmail} hitting reset generates a warning "" does not appear to be an e-mail address - This has no valid default.
  • entering a char into a NUMBER field generates a javascript alert() ... should be reported as the other validation errors using the red error box - Not going to be fixed (by CDot, anyway)
  • even without saving any changes and after having done lots of testing (see above) the main foswiki.fcgi process gets busted and I get this in the logs. Only way to revive the site is to restart apache and foswiki.
    "Can't use string ("ARRAY(0x12a55388)") as an ARRAY ref while "strict refs" in use at /home/www-data/foswiki/core/lib/Foswiki.pm line 1918"

Stopped testing at "Mail". There are probably more errors in the other config sections.

-- MichaelDaum - 29 Jan 2015

Thanks Michael, that was really useful. I fixed the low hanging fruit, but there are a couple of notes above that need looking at more closely.

-- CrawfordCurrie - 29 Jan 2015

FindBin might fail to compile under certain conditions such as running Foswiki under VirtualHostingContrib. This in turn stops SCRIPTHASH from being loaded. Below patch disables FindBin in there. However a more sensible way to deal with this would be to catch any compile error of FindBin for more robustness.

The reason Findbin fails to compile is caused by its inability to derive the script's location on the filesystem. FastCGIEngineContrib as well as VirtualHostingContrib and WebDAVContrib manipulate the process name while forking the worke pool of Foswiki backends. So FindBin is applicable in these situations and it certainly should not result in a compile error.

diff --git a/core/lib/Foswiki/Configure/Pluggables/SCRIPTHASH.pm b/core/lib/Foswiki/Configure/Pluggables/SCRIPTHASH.pm
index 782f26a..3a01a77 100644
--- a/core/lib/Foswiki/Configure/Pluggables/SCRIPTHASH.pm
+++ b/core/lib/Foswiki/Configure/Pluggables/SCRIPTHASH.pm
@@ -13,7 +13,7 @@ use strict;
 use warnings;
 
 use File::Spec ();
-use FindBin    ();
+#use FindBin    ();
 
 use Assert;
 use Foswiki::Configure::LoadSpec ();
@@ -23,7 +23,7 @@ sub construct {
 
     my $bindir = $Foswiki::cfg{ScriptDir};
     unless ($bindir) {
-        $bindir = $FindBin::Bin;
+        #$bindir = $FindBin::Bin;
         unless ( -e "$bindir/setlib.cfg" ) {
             $bindir =

-- MichaelDaum - 30 Jan 2015

Noticed $Foswiki::cfg{Engine} is undefined for the checkers. When the cfg hash is emptied, the auto-set Engine needs to be preserved. Checking in a fix.

-- GeorgeClark - 19 Feb 2015
 

Topic revision: r26 - 04 Mar 2015, GeorgeClark
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