You are here: Foswiki>Tasks Web>Item14374 (03 Jun 2017, GeorgeClark)Edit Attach

Item14374: .changes file corruption on trunk.foswiki.org causes Use of Uninitialized Variable

pencil
Priority: Normal
Current State: Confirmed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: RCSStoreContrib, FoswikiUIChanges
Branches:
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
Not sure of the root cause, but this needs to be a bit more robust.

The .changes file appears to be a hybrid of the old tabular format and the new JSON format.

?       LucasScott      1467981692      1       {"revision":"1","path":"Main.LucasScottLeftBar","topic":null,"verb":"insert","minor":null,"cuid":"LucasScott","time":1467981692}

And the resulting crash:

Use of uninitialized value in hash element at /var/www/trunk.foswiki.org/core/lib/Foswiki/UI/Changes.pm line 67.
 at /var/www/.plenv/versions/5.22.2/lib/perl5/site_perl/5.22.2/CGI/Carp.pm line 362.
   CGI::Carp::realdie("Use of uninitialized value in hash element at /var/www/trunk."...) called at /var/www/.plenv/versions/5.22.2/lib/perl5/site_perl/5.22.2/CGI/Carp.pm line 454
   CGI::Carp::die("Use of uninitialized value in hash element at /var/www/trunk."...) called at /var/www/trunk.foswiki.org/core/lib/AssertOn.pm line 15
   Assert::__ANON__("Use of uninitialized value in hash element at /var/www/trunk."...) called at /var/www/trunk.foswiki.org/core/lib/Foswiki/UI/Changes.pm line 67
   Foswiki::UI::Changes::changes(Foswiki=HASH(0x1ec6350)) called at /var/www/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 378
   Foswiki::UI::__ANON__() called at /var/www/.plenv/versions/5.22.2/lib/perl5/site_perl/5.22.2/Error.pm line 421
   eval {...} called at /var/www/.plenv/versions/5.22.2/lib/perl5/site_perl/5.22.2/Error.pm line 413
   Error::subs::try(CODE(0x8476d0), HASH(0x1ec5d98)) called at /var/www/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 504
   Foswiki::UI::_execute(Foswiki::Request=HASH(0x1e6c958), CODE(0x1ca6978), "changes", 1) called at /var/www/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 330
   Foswiki::UI::handleRequest(Foswiki::Request=HASH(0x1e6c958)) called at /var/www/trunk.foswiki.org/core/lib/Foswiki/Engine/CGI.pm line 100
   Foswiki::Engine::CGI::run(Foswiki::Engine::CGI=HASH(0x16c6c50)) called at /var/www/trunk.foswiki.org/core/bin/changes line 31.

-- GeorgeClark - 09 Apr 2017

Confirming this as an issue in the tabular format of the .changes file. As this is only needed when sharing a store with Foswiki 1.x, I suspect we could just remove this compatibiblity feature in Foswiki 2.2 or 3

The issue is that eachChangeSince is returning some undefined fields when the .changes file is in tabular format:
$VAR1 = \{
            'cuid' => 'BaseUserMapping_333',
            'revision' => 1,
            'path' => 'Sandbox.FooBar',
            'topic' => undef,
            'more' => '{"minor":null,"path":"Sandbox.FooBar","time":1496450922,"cuid":"BaseUserMapping_333","revision":1,"verb":"insert","topic":null}',
            'time' => 1496450922,
            'verb' => 'insert',
            'user' => 'BaseUserMapping_333',
            'minor' => undef
          };
And the code is expecting that the topic => field is present, so that duplicate change records can be skipped.

-- GeorgeClark - 03 Jun 2017

This seems to be the fix.
diff --git a/RCSStoreContrib/lib/Foswiki/Store/Rcs/Handler.pm b/RCSStoreContrib/lib/Foswiki/Store/Rcs/Handler.pm
index 6768f84..fddb838 100644
--- a/RCSStoreContrib/lib/Foswiki/Store/Rcs/Handler.pm
+++ b/RCSStoreContrib/lib/Foswiki/Store/Rcs/Handler.pm
@@ -1639,6 +1639,12 @@ sub readChanges {
                 while ( my ( $k, $v ) = each %$decoded ) {
                     $row{$k} = $v;
                 }
+                if ( $row{path} && $row{path} =~ /^(.*)\.(.*)$/ ) {
+                    $row{topic} = $2;
+                }
+                elsif ( $row{oldpath} && $row{oldpath} =~ /^(.*)\.(.*)$/ ) {
+                    $row{topic} = $2;
+                }
                 $ok = 1;
             };
         }

-- GeorgeClark - 03 Jun 2017
 

ItemTemplate edit

Summary .changes file corruption on trunk.foswiki.org causes Use of Uninitialized Variable
ReportedBy GeorgeClark
Codebase
SVN Range
AppliesTo Extension
Component RCSStoreContrib, FoswikiUIChanges
Priority Normal
CurrentState Confirmed
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release02x01Checkins
Release02x00Checkins
Release01x01Checkins
Topic revision: r2 - 03 Jun 2017, 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