Anonymous Login
2016-09-26 15:53 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
04996Bug reports[All Projects] Import/Exportpublic2011-03-10 12:28
Reporteryohann 
Assigned Tolemeur 
PriorityhighSeveritymajor 
StatusclosedResolutionfixed 
Product Version1.91RC4 
Target VersionFixed in Version1.91RC5 
Summary04996: Conditions based on Token attributes are exported in xml but aren't imported
Descriptioncondition based on token:attribute_1 == constant aren't imported, export give the fallowing:
<row>
  <cid><![CDATA[215]]></cid>
  <qid><![CDATA[56]]></qid>
  <scenario><![CDATA[1]]></scenario>
  <cqid><![CDATA[0]]></cqid>
  <cfieldname><![CDATA[{TOKEN:ATTRIBUTE_1}]]></cfieldname>
  <method><![CDATA[==]]></method>
  <value><![CDATA[Auto-RĂ©pondant]]></value>
</row>
but once imported, the condition dispear
Steps To Reproducecreate a condition based on token:attribute
export survey
check lss file : the condition is here
import lss file : the condition isn't here anymore
Complete LimeSurvey version number (& build)9716
I will donate to the project if issue is resolvedNo
Browserfirefox
Database & DB-Version145
Operating System (Server)Linux (Ubuntu)
Webserver software & versionapache2
PHP Version5.3.3-1ubuntu9.3 with Suhosin-Patch (cli) (built: Jan 12 2011 16:08:14)
Attached Files
  • patch file icon import_function.patch (2,023 bytes) 2011-03-03 16:45 -
    --- import_functions.php.orig	2011-03-03 16:05:27.801926002 +0100
    +++ import_functions.php	2011-03-03 16:34:45.301926002 +0100
    @@ -1404,7 +1404,7 @@
                     $insertdata[(string)$key]=(string)$value;
                 }
                 // replace the qid for the new one (if there is no new qid in the $aQIDReplacements array it mean that this condition is orphan -> error, skip this record)
    -            if (isset($aQIDReplacements[$insertdata['qid']]))
    +            if (isset($aQIDReplacements[$insertdata['qid']]) )
                 {
                     $insertdata['qid']=$aQIDReplacements[$insertdata['qid']]; // remap the qid
                 }
    @@ -1412,11 +1412,18 @@
                 if (isset($aQIDReplacements[$insertdata['cqid']]))
                 {
                     $insertdata['cqid']=$aQIDReplacements[$insertdata['cqid']]; // remap the qid
    +                list($oldcsid, $oldcgid, $oldqidanscode) = explode("X",$insertdata["cfieldname"],3);
    +            }
    +            elseif (strpos($insertdata['cfieldname'], 'TOKEN:ATTRIBUTE_') !== false)  // condition is valid but based on token attribute instead of previous question
    +            {
    +              // this is a bit dirty but i don't want to move to much of existing code so i do the sstuff here and then continue
    +              $query=$connect->GetInsertSQL($tablename,$insertdata);
    +              $result=$connect->Execute($query) or safe_die ($clang->gT("Error").": Failed to insert data<br />\$query<br />\n".$connect->ErrorMsg());
    +              $results['conditions']++;
    +              continue;
                 }
                 else continue; // a problem with this answer record -> don't consider
     
    -            list($oldcsid, $oldcgid, $oldqidanscode) = explode("X",$insertdata["cfieldname"],3);
    -
                 // replace the gid for the new one in the cfieldname(if there is no new gid in the $aGIDReplacements array it means that this condition is orphan -> error, skip this record)
                 if (!isset($aGIDReplacements[$oldcgid]))
                     continue;
    
    patch file icon import_function.patch (2,023 bytes) 2011-03-03 16:45 +
  • patch file icon import_functions.patch (2,065 bytes) 2011-03-07 15:50 -
    --- import_functions.php.orig	2011-03-03 16:05:27.801926002 +0100
    +++ import_functions.php	2011-03-04 14:41:24.633098003 +0100
    @@ -1404,7 +1404,7 @@
                     $insertdata[(string)$key]=(string)$value;
                 }
                 // replace the qid for the new one (if there is no new qid in the $aQIDReplacements array it mean that this condition is orphan -> error, skip this record)
    -            if (isset($aQIDReplacements[$insertdata['qid']]))
    +            if (isset($aQIDReplacements[$insertdata['qid']]) )
                 {
                     $insertdata['qid']=$aQIDReplacements[$insertdata['qid']]; // remap the qid
                 }
    @@ -1412,11 +1412,19 @@
                 if (isset($aQIDReplacements[$insertdata['cqid']]))
                 {
                     $insertdata['cqid']=$aQIDReplacements[$insertdata['cqid']]; // remap the qid
    +                list($oldcsid, $oldcgid, $oldqidanscode) = explode("X",$insertdata["cfieldname"],3);
    +            }
    +            elseif (strpos($insertdata['cfieldname'], 'TOKEN:ATTRIBUTE_') !== false)  // condition is valid but based on token attribute instead of previous question
    +            {
    +              // this is a bit dirty but i don't want to move to much of existing code so i do the sstuff here and then continue
    +              unset($insertdata["cid"]);
    +              $query=$connect->GetInsertSQL($tablename,$insertdata);
    +              $result=$connect->Execute($query) or safe_die ($clang->gT("Error").": Failed to insert data<br />\$query<br />\n".$connect->ErrorMsg());
    +              $results['conditions']++;
    +              continue;
                 }
                 else continue; // a problem with this answer record -> don't consider
     
    -            list($oldcsid, $oldcgid, $oldqidanscode) = explode("X",$insertdata["cfieldname"],3);
    -
                 // replace the gid for the new one in the cfieldname(if there is no new gid in the $aGIDReplacements array it means that this condition is orphan -> error, skip this record)
                 if (!isset($aGIDReplacements[$oldcgid]))
                     continue;
    
    patch file icon import_functions.patch (2,065 bytes) 2011-03-07 15:50 +

-Relationships
+Relationships

-Notes

~14312

yohann (reporter)

here is a patch (a bit dirty but works for me)

if cqid is 0 it doesn't just skip the condition, but instead look for "TOKEN_ATTRIBUTE" in cfiedname, if there is a string like that we insert conditions data and increment condition counter before we continue

~14317

yohann (reporter)

Sorry about the first patch, i forgot to unsed cid so it works the first time, but fail once the id of condidion exists, the second patch is better (one line more which unset cid before insert condition in database)

~14321

lemeur (developer)

Fixed in rev 9851 and 9852.
Thx for the detailed anaylis of the pb.

~14379

c_schmitz (administrator)

1.91RC5 released.
+Notes

-Issue History
Date Modified Username Field Change
2011-03-03 15:59 yohann New Issue
2011-03-03 16:45 yohann Note Added: 14312
2011-03-03 16:45 yohann File Added: import_function.patch
2011-03-07 15:50 yohann File Added: import_functions.patch
2011-03-07 15:52 yohann Note Added: 14317
2011-03-07 16:55 Mazi Assigned To => lemeur
2011-03-07 16:55 Mazi Status new => assigned
2011-03-07 18:35 lemeur Note Added: 14321
2011-03-07 18:35 lemeur Status assigned => resolved
2011-03-07 18:35 lemeur Fixed in Version => 1.91RC5
2011-03-07 18:35 lemeur Resolution open => fixed
2011-03-10 12:28 c_schmitz Note Added: 14379
2011-03-10 12:28 c_schmitz Status resolved => closed
+Issue History