You are here: Foswiki>Tasks Web>Item10965 (14 Jul 2011, MichaelDaum)Edit Attach

Item10965: when list has zero in it - filterplugin don't work

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: FilterPlugin
Branches:
Reported By: GrzegorzMarszalek
Waiting For:
Last Change By: MichaelDaum
example: FORMATLIST{"0,1,2,3" format=" * $1" separator="$n"} will display:

  • 0
  • 1
  • 2
  • 3

so 0 is missing...

problem is in handleFormatList function - earch argument is detected with code $arg1 = $1 || ''; - so, when $1 is '0', perl converts it to int and 0 means false - so $arg1 get assigned '' as its value.

patch (which also solve problem when you five FORMATLIST list with 1 element which is zero - ie.: FORMATLIST{"0"}):

--- Core.pm 2011-04-06 13:08:53.000000000 +0200
+++ Core.pm.new 2011-07-13 09:25:02.000000000 +0200
@@ -502,7 +502,9 @@ sub handleFormatList {

   #writeDebug("handleFormatList(".$params->stringify().")");

-  my $theList = $params->{_DEFAULT} || $params->{list} || '';
+  my $theList = defined($params->{_DEFAULT}) ? $params->{_DEFAULT} :
+    defined($params->{list}) ? $params->{list} :
+    '';
   my $thePattern = $params->{pattern} || '^\s*(.*?)\s*$';
   my $theFormat = $params->{format};
   my $theHeader = $params->{header} || '';
@@ -588,16 +590,16 @@ sub handleFormatList {
     my $arg9 = '';
     my $arg10 = '';
     if ($item =~ m/$thePattern/) {
-      $arg1 = $1 || '';
-      $arg2 = $2 || '';
-      $arg3 = $3 || '';
-      $arg4 = $4 || '';
-      $arg5 = $5 || '';
-      $arg6 = $6 || '';
-      $arg7 = $7 || '';
-      $arg8 = $8 || '';
-      $arg9 = $9 || '';
-      $arg10 = $10 || '';
+      $arg1 = defined($1) ? $1 : '';
+      $arg2 = defined($2) ? $2 : '';
+      $arg3 = defined($3) ? $3 : '';
+      $arg4 = defined($4) ? $4 : '';
+      $arg5 = defined($5) ? $5 : '';
+      $arg6 = defined($6) ? $6 : '';
+      $arg7 = defined($7) ? $7 : '';
+      $arg8 = defined($8) ? $8 : '';
+      $arg9 = defined($9) ? $9 : '';
+      $arg10 = defined($10) ? $10 : '';
     } else {
       next;
     }

-- GrzegorzMarszalek

I copied this report from Support.Question893.

-- PaulHarvey - 14 Jul 2011

Fixed in 2.05

-- MichaelDaum - 14 Jul 2011
 

ItemTemplate edit

Summary when list has zero in it - filterplugin don't work
ReportedBy GrzegorzMarszalek
Codebase trunk
SVN Range
AppliesTo Extension
Component FilterPlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins FilterPlugin:7403a0ff3466 FilterPlugin:e416b785fd05
TargetRelease n/a
ReleasedIn n/a
Topic revision: r3 - 14 Jul 2011, MichaelDaum
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