Anonymous Login
2016-09-25 20:59 CEST

View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
07629Bug reports[All Projects] RemoteControlpublic2013-03-05 08:45
Reportermfaber 
Assigned Toc_schmitz 
PrioritynormalSeveritycrash 
StatusclosedResolutionfixed 
Product Version2.00+ 
Target VersionFixed in Version2.00+ 
Summary07629: fatal error on unexpected key/data in response array (RPC add_response)
Description
Using the JSON-RPC add_response function I add answers to the
Limesurvey-DB. However, if the array with the responses contains keys
or values that are not part of the target survey table, a fatal error
occurs:

Fatal error: Uncaught exception 'Exception' with message 'Request
error: Property "Survey_dynamic.testkey" is not defined.' in
C:\survey\htdocs\limesurvey\application\libraries\jsonRPCClient.php:157
Stack trace: #0 C:\survey\htdocs\HTML5\scripts\export.php(58):
jsonRPCClient->__call('add_response', Array) #1
C:\survey\htdocs\HTML5\scripts\export.php(58):
jsonRPCClient->add_response('ehp7cuv63tjztbp...', 542856, Array) #2
{main} thrown in C:\survey\htdocs\limesurvey\application\libraries\jsonRPCClient.php on
line 157

I would expect the add_response function to either ignore such "additional"
data or return an error code but still add all responses that fit.

Steps To ReproduceHere's a code snippet that I'm using to test:

$post="542856X167X1616=Y&542856X168X1617=12&542856X168X1618=F&542856X168X1619=6&542856X169X1620=Y&542856X169X1621=&542856X169X1622SQ001=Y&542856X169X1622SQ002=U&542856X169X1622SQ003=N&542856X169X1622SQ004=Y&542856X169X1622SQ005=U&542856X170X1623=Y&542856X170X1624SQ001=Y&542856X170X1624SQ002=U&542856X170X1624SQ003=N&542856X170X1624SQ004=&testkey=";

// convert string to an associative array
parse_str($post, $output);

// does it look ok?
print_r($output);

//add response to the LS database
$responseadded=$myJSONRPCClient->add_response($sSessionKey, $survey_id, $output);

// show the reponse code
print_r($responseadded);
Additional InformationThis is the array that works ok IF the last key [testkey] is not part of
it:

Array ( [542856X167X1616] => Y [542856X168X1617] => 12
[542856X168X1618] => F [542856X168X1619] => 6 [542856X169X1620] => Y
[542856X169X1621] => [542856X169X1622SQ001] => Y [542856X169X1622SQ002]
=> U [542856X169X1622SQ003] => N [542856X169X1622SQ004] => Y
[542856X169X1622SQ005] => U [542856X170X1623] => Y
[542856X170X1624SQ001] => Y [542856X170X1624SQ002] => U
[542856X170X1624SQ003] => N [542856X170X1624SQ004] => [testkey] => )
 
I would expect the add_response function to either ignore unexpected "additional" data or return an error code but still add all responses that fit.
Complete LimeSurvey version number (& build)130226
I will donate to the project if issue is resolvedNo
BrowserChrome
Database & DB-VersionMySQL 5.0.1.0 (XAMPP)
Operating System (Server)WinXP
Webserver software & versionApache/2.4.3 (Win32) OpenSSL/1.0.1c (XAMPP)
PHP VersionPHP/5.4.7 (XAMPP)
Attached Files
  • txt file icon responsedata.txt (639 bytes) 2013-03-02 09:58 -
    Array
    (
        [542856X167X1616] => Y
        [542856X168X1617] => 12
        [542856X168X1618] => F
        [542856X168X1619] => 6
        [542856X169X1620] => Y
        [542856X169X1621] => 
        [542856X169X1622SQ001] => Y
        [542856X169X1622SQ002] => U
        [542856X169X1622SQ003] => N
        [542856X169X1622SQ004] => Y
        [542856X169X1622SQ005] => U
        [542856X170X1623] => Y
        [542856X170X1624SQ001] => Y
        [542856X170X1624SQ002] => U
        [542856X170X1624SQ003] => N
        [542856X170X1624SQ004] => 
        [submitdate] => 2013-03-02 09:54:59
        [startlanguage] => de-informal
        [datestamp] => 2013-03-02 09:54:59
        [startdate] => 2013-03-02 09:54:59
    )
    
    txt file icon responsedata.txt (639 bytes) 2013-03-02 09:58 +
  • txt file icon destination.txt (640 bytes) 2013-03-02 09:59 -
    Array
    (
        [0] => id
        [1] => token
        [2] => submitdate
        [3] => lastpage
        [4] => startlanguage
        [5] => startdate
        [6] => datestamp
        [7] => 542856X167X1616
        [8] => 542856X168X1617
        [9] => 542856X168X1618
        [10] => 542856X168X1619
        [11] => 542856X169X1620
        [12] => 542856X169X1621
        [13] => 542856X169X1622SQ001
        [14] => 542856X169X1622SQ002
        [15] => 542856X169X1622SQ003
        [16] => 542856X169X1622SQ004
        [17] => 542856X169X1622SQ005
        [18] => 542856X170X1623
        [19] => 542856X170X1624SQ001
        [20] => 542856X170X1624SQ002
        [21] => 542856X170X1624SQ003
        [22] => 542856X170X1624SQ004
    )
    
    txt file icon destination.txt (640 bytes) 2013-03-02 09:59 +
  • txt file icon intersect.txt (10 bytes) 2013-03-02 10:00 -
    Array
    (
    )
    
    txt file icon intersect.txt (10 bytes) 2013-03-02 10:00 +

-Relationships
+Relationships

-Notes

~24448

c_schmitz (administrator)

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=11705

~24460

mfaber (developer)

Thanks for the super quick reaction. Unfortunatly, now, no answers at all are imported.
A new response set is created and the corresponding number is returned in the response code of RPC's add_response but all values are [missing].

~24461

mfaber (developer)

c_schmitz,
to help find the problem, I wrote the content of the 3 arrays $aBasicDestinationFields, $aResponseData before and after array_intersect in three different files (attached).

The intersection does not seems to work. I tried with array_intersect_key but to no avail. If I can do anything else, please let me know.

~24462

mfaber (developer)

It works with line 2260 as follows (flipped destination array and used array_intersect_key):

$aResponseData=array_intersect_key($aResponseData, array_flip($aBasicDestinationFields));

Please check before implementing if this is ok, i am not a programmer and i am just learning a bit of PHP through limesurvey.

~24463

c_schmitz (administrator)

Hello!,

Yes, that's the correct solution. Very nice!

~24464

c_schmitz (administrator)

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=11709

~24490

c_schmitz (administrator)

Fix committed to 2.1 branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=11738

~24533

c_schmitz (administrator)

2.00+ Build 130305 released.
+Notes

+Related Changesets

-Issue History
Date Modified Username Field Change
2013-03-01 14:06 mfaber New Issue
2013-03-01 14:41 c_schmitz Assigned To => c_schmitz
2013-03-01 14:41 c_schmitz Status new => assigned
2013-03-01 14:42 c_schmitz Changeset attached => LimeSurvey master 97a166e4
2013-03-01 14:42 c_schmitz Note Added: 24448
2013-03-01 14:42 c_schmitz Resolution open => fixed
2013-03-01 14:43 c_schmitz Status assigned => resolved
2013-03-01 14:43 c_schmitz Fixed in Version => 2.00+
2013-03-01 21:59 mfaber Note Added: 24460
2013-03-01 21:59 mfaber Status resolved => feedback
2013-03-01 21:59 mfaber Resolution fixed => reopened
2013-03-02 09:58 mfaber File Added: responsedata.txt
2013-03-02 09:59 mfaber File Added: destination.txt
2013-03-02 10:00 mfaber File Added: intersect.txt
2013-03-02 10:02 mfaber Note Added: 24461
2013-03-02 10:02 mfaber Status feedback => assigned
2013-03-02 12:24 mfaber Note Added: 24462
2013-03-02 14:10 c_schmitz Note Added: 24463
2013-03-02 14:16 c_schmitz Status assigned => resolved
2013-03-02 14:16 c_schmitz Resolution reopened => fixed
2013-03-02 14:16 c_schmitz Changeset attached => LimeSurvey master 78f17a30
2013-03-02 14:16 c_schmitz Note Added: 24464
2013-03-02 16:34 c_schmitz Changeset attached => LimeSurvey 2.1 fca41d2a
2013-03-02 16:34 c_schmitz Note Added: 24490
2013-03-05 08:45 c_schmitz Note Added: 24533
2013-03-05 08:45 c_schmitz Status resolved => closed
+Issue History