You are here: Foswiki>Tasks Web>Item12129 (08 Dec 2016, GeorgeClark)Edit Attach

Item12129: EDITTABLE breaks FOSWIKI on INCLUDE

pencil
Priority: Urgent
Current State: Closed
Released In: 1.2.0
Target Release: minor
Applies To: Engine
Component: EditTablePlugin
Branches: trunk
Reported By: StefanosKouzof
Waiting For:
Last Change By: GeorgeClark
When using latest editions of FOSWIKI and EDITTABLE, and use other topic to define the EDITTABLE parameters, FOSWIKI crashes with the following error:

Can't use string ("Sandbox") as a HASH ref while "strict refs" in use
I used the Sandbox web, where even the table definition did not exist. To repeat it, just insert an EDITTABLE with "include" somewhere in a topic, eg:

%EDITTABLE{ include = "BudgetCaseTable" }%

I have seen a lot of this kind of errors in FormPlugin as well. Where is the error trapping? Something does not feel right.

-- StefanosKouzof - 08 Oct 2012

Confirmed on trunk. See Sandbox TestItem12129 (Not linking so the bots don't follow.

-- GeorgeClark - 07 Nov 2012 - 17:25

I can't recreate this on 1.1.6, using the Release01x01 version of EditTablePlugin. See http://foswiki.org/Tasks/Testcases/TestItem12129

-- GeorgeClark - 07 Nov 2012

I have a fix, the issue is trunk only and is in the new core Table Reader code. It attempts to process the include even if it doesn't exist, and also uses core topicExists, instead of Func, which seems to be more robust.

I'm not checking this in because I cannot get the EditTablePlugin tests to run on trunk, and I have been unable to trigger the EditRowPlugin tests to fail. I've added bogus include statements to various EDITTABLE macros in the EditRowPlugin tests, and everything still works. But this patch does fix the crash in a real web environment.

diff --git a/core/lib/Foswiki/Tables/Reader.pm b/core/lib/Foswiki/Tables/Reader.pm
index 838fce0..9a3c73a 100644
--- a/core/lib/Foswiki/Tables/Reader.pm
+++ b/core/lib/Foswiki/Tables/Reader.pm
@@ -123,24 +123,27 @@ sub early_line {
         my ( $iw, $it ) =
           Foswiki::Func::normalizeWebTopicName( $this->{meta}->web,
             $attrs->{include} );
-        unless ( Foswiki::topicExists( $iw, $it ) ) {
+        unless ( Foswiki::Func::topicExists( $iw, $it ) ) {
             $line = CGI::span( { class => 'foswikiAlert' },
                 "Could not find format topic $attrs->{include}" );
+            $attrs->{include} = '';
         }
-        if ( $read{"$iw.$it"} ) {
-            $line = CGI::span( { class => 'foswikiAlert' },
-                "Recursive include of $attrs->{include}" );
-        }
-        $read{"$iw.$it"} = 1;
-        my $meta = Foswiki::Meta->load( $this->{meta}->session, $iw, $it );
-        my $params = '';
-        if ( $meta->text =~ m/%$this->{macro}(?:{([^\n]*)})?%/s ) {
-            $params = $1;
-        }
-        if ($params) {
-            $params = $meta->expandMacros($params);
+        else {
+            if ( $read{"$iw.$it"} ) {
+                $line = CGI::span( { class => 'foswikiAlert' },
+                    "Recursive include of $attrs->{include}" );
+            }
+            $read{"$iw.$it"} = 1;
+            my $meta = Foswiki::Meta->load( $this->{meta}->session, $iw, $it );
+            my $params = '';
+            if ( $meta->text =~ m/%$this->{macro}(?:{([^\n]*)})?%/s ) {
+                $params = $1;
+            }
+            if ($params) {
+                $params = $meta->expandMacros($params);
+            }
+            $attrs = Foswiki::Attrs->new($params);
         }
-        $attrs = Foswiki::Attrs->new($params);
     }
 
     $this->adjustSpec($attrs);

-- GeorgeClark - 07 Nov 2012

Crawford. This still fails on trunk, See Sandbox TestItem12129 I think my fix is good but I was having unit test issues.

-- GeorgeClark - 20 Dec 2013

Should be OK now.

-- CrawfordCurrie - 20 Feb 2014

 
Topic revision: r8 - 08 Dec 2016, 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