Item1384: Creating webs with empty field values in the submit form fails

pencil
Priority: Urgent
Current State: Closed
Released In: 1.0.5
Target Release: patch
Applies To: Engine
Component:
Branches:
Reported By: SvenDowideit
Waiting For:
Last Change By: KennethLavrsen
found it on trunk - unsure about release atm

TemplateAuth issue i suspect..

  1. start not-logged in
  2. goto ManagingWebs and create a new web. (choosing/entering some non-default options)
  3. you should get re-directed to the login screen
  4. log in as admin
  5. your web will be created, but the settings you choose do not get written, if ASSERTs are on, you will likey see a crash as the values are lost.

if you do this already logged in, it works.

-- SvenDowideit - 29 Mar 2009

I couldn't reproduce that, not on trunk, not on the release branch.

By "log in as admin", you mean as an admin user, or something else?

My settings were written, but the only settings you can specify are the colo, description, and searchall, thinks like that. And I always run with ASSERTs on, so this didn't catch it either.

-- OlivierRaginel - 30 Mar 2009

Can't reproduce it on trunk either. All works fine for me.

-- CrawfordCurrie - 31 Mar 2009

Ok, I could reproduce it! The problem is why the "admin" login. You have to login as admin, not an admin user, which was my interogation.

When I login as admin, with ASSERTs on, I get:
Use of uninitialized value in concatenation (.) or string at /.../core/lib/Foswiki/Meta.pm line 367.
	at /usr/share/perl/5.10/CGI/Carp.pm line 356
    CGI::Carp::realdie('Use of uninitialized value in concatenation (.) or string at ...') called at /usr/share/perl/5.10/CGI/Carp.pm line 437
    CGI::Carp::die('Use of uninitialized value in concatenation (.) or string at ...') called at /.../core/lib/Foswiki.pm line 153
    Foswiki::__ANON__('Use of uninitialized value in concatenation (.) or string at ...') called at /.../core/lib/Foswiki/Meta.pm line 367
    Foswiki::Meta::populateNewWeb('Foswiki::Meta=HASH(0x246f480)', 'TestCases', 'HASH(0x246f558)') called at /.../core/lib/Foswiki/UI/Manage.pm line 186
    Foswiki::UI::Manage::__ANON__() called at /usr/share/perl5/Error.pm line 416
    eval {...} called at /usr/share/perl5/Error.pm line 408
    Error::subs::try('CODE(0x246f5a0)', 'HASH(0x246f7e0)') called at /.../core/lib/Foswiki/UI/Manage.pm line 194
    Foswiki::UI::Manage::_action_createweb('Foswiki=HASH(0x242a420)') called at /.../core/lib/Foswiki/UI/Manage.pm line 44
    Foswiki::UI::Manage::manage('Foswiki=HASH(0x242a420)') called at /.../core/lib/Foswiki/UI.pm line 183
    Foswiki::UI::__ANON__() called at /usr/share/perl5/Error.pm line 416
    eval {...} called at /usr/share/perl5/Error.pm line 408
    Error::subs::try('CODE(0x200cb10)', 'HASH(0x246f090)') called at /.../core/lib/Foswiki/UI.pm line 252
    Foswiki::UI::execute('Foswiki::Request=HASH(0x242a8d0)', 'CODE(0x242a348)', 'manage', 1) called at /.../core/lib/Foswiki/UI.pm line 121
    Foswiki::UI::handleRequest('Foswiki::Request=HASH(0x242a8d0)') called at /.../core/lib/Foswiki/Engine/CGI.pm line 26
    Foswiki::Engine::CGI::run('Foswiki::Engine::CGI=HASH(0x2240a40)') called 

Therefore, I propose the following patch, which seems to fix it on my test installation:
diff --git a/core/lib/Foswiki/Meta.pm b/core/lib/Foswiki/Meta.pm
index 261f869..9fa93d1 100644
--- a/core/lib/Foswiki/Meta.pm
+++ b/core/lib/Foswiki/Meta.pm
@@ -365,7 +365,8 @@ sub populateNewWeb {
         my $text = $prefsTopicObject->text;
         foreach my $key (keys %$opts) {
             $text =~
-              s/($Foswiki::regex{setRegex}$key\s*=).*?$/$1 $opts->{$key}/gm;
+              s/($Foswiki::regex{setRegex}$key\s*=).*?$/$1 $opts->{$key}/gm
+                if defined $opts->{$key};
         }
         $prefsTopicObject->text($text);
         $prefsTopicObject->save();

For the record, in my test, the following keys were undefined:
  • SITEMAPLIST
  • NEWTOPIC

-- OlivierRaginel - 31 Mar 2009

I like your patch.

-- CrawfordCurrie - 01 Apr 2009

I have reproduced the error and fixed it using Oliviers patch. In Release01x00 I had to find the same code piece in Store.pm

-- KennethLavrsen - 21 Apr 2009

ItemTemplate edit

Summary Creating webs with empty field values in the submit form fails
ReportedBy SvenDowideit
Codebase trunk
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Engine
Component
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:b33567cb6f4e
TargetRelease patch
ReleasedIn 1.0.5
Topic revision: r10 - 25 Apr 2009, KennethLavrsen
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