View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
07629Bug reportsRemoteControlpublic2013-03-05 08:45
Reportermfaber Assigned Toc_schmitz  
PrioritynormalSeverityblock 
Status closedResolutionfixed 
Product Version2.00+ 
Fixed 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 Reproduce

Here'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 Information

This 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.

TagsNo tags attached.
Attached Files
responsedata.txt (639 bytes)   
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
)
responsedata.txt (639 bytes)   
destination.txt (640 bytes)   
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
)
destination.txt (640 bytes)   
intersect.txt (10 bytes)   
Array
(
)
intersect.txt (10 bytes)   
Bug heat6
Complete LimeSurvey version number (& build)130226
I will donate to the project if issue is resolvedNo
BrowserChrome
Database type & versionMySQL 5.0.1.0 (XAMPP)
Server OS (if known)WinXP
Webserver software & version (if known)Apache/2.4.3 (Win32) OpenSSL/1.0.1c (XAMPP)
PHP VersionPHP/5.4.7 (XAMPP)

Users monitoring this issue

mfaber

Activities

c_schmitz

c_schmitz

2013-03-01 14:42

administrator   ~24448

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

mfaber

mfaber

2013-03-01 21:59

reporter   ~24460

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].

mfaber

mfaber

2013-03-02 10:02

reporter   ~24461

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.

mfaber

mfaber

2013-03-02 12:24

reporter   ~24462

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.

c_schmitz

c_schmitz

2013-03-02 14:10

administrator   ~24463

Hello!,

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

c_schmitz

c_schmitz

2013-03-02 14:16

administrator   ~24464

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

c_schmitz

c_schmitz

2013-03-02 16:34

administrator   ~24490

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

c_schmitz

c_schmitz

2013-03-05 08:45

administrator   ~24533

2.00+ Build 130305 released.

Related Changesets

LimeSurvey: master 97a166e4

2013-03-01 13:42:21

c_schmitz

Details Diff
Fixed issue 07629: Fatal error on unexpected key/data when using RPC function add_response Affected Issues
07629
mod - application/controllers/admin/remotecontrol.php Diff File

LimeSurvey: master 78f17a30

2013-03-02 13:16:33

c_schmitz

Details Diff
Fixed issue 07629: Fatal error on unexpected key/data when using RPC function add_response Affected Issues
07629
mod - application/controllers/admin/remotecontrol.php Diff File

LimeSurvey: 2.1 fca41d2a

2013-03-02 14:37:50

c_schmitz

Details Diff
Fixed issue 07629: Fatal error on unexpected key/data when using RPC function add_response Affected Issues
07629
mod - application/controllers/admin/remotecontrol.php Diff File

Issue History

Date Modified Username Field Change
2013-03-01 14:06 mfaber New Issue
2013-03-01 14:19 mfaber Issue Monitored: mfaber
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
2021-08-03 23:10 guest Bug heat 4 => 6