LimeSurvey issue tracker
Registration

View Issue Details Jump to Notes ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
07629Bug reports[All Projects] RemoteControlpublic2013-03-01 14:062013-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.
I will donate to the project if issue is resolved within 48 hrsNo
LimeSurvey build number OR git commit ID130226
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 Filestxt file icon responsedata.txt [^] (639 bytes) 2013-03-02 09:58 [Show Content]
txt file icon destination.txt [^] (640 bytes) 2013-03-02 09:59 [Show Content]
txt file icon intersect.txt [^] (10 bytes) 2013-03-02 10:00 [Show Content]

- Relationships

-  Notes
User avatar (24448)
c_schmitz (administrator)
2013-03-01 14:42

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=11705 [^]
User avatar (24460)
mfaber (developer)
2013-03-01 21:59

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].
User avatar (24461)
mfaber (developer)
2013-03-02 10:02

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.
User avatar (24462)
mfaber (developer)
2013-03-02 12:24

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.
User avatar (24463)
c_schmitz (administrator)
2013-03-02 14:10

Hello!,

Yes, that's the correct solution. Very nice!
User avatar (24464)
c_schmitz (administrator)
2013-03-02 14:16

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=11709 [^]
User avatar (24490)
c_schmitz (administrator)
2013-03-02 16:34

Fix committed to 2.1 branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=11738 [^]
User avatar (24533)
c_schmitz (administrator)
2013-03-05 08:45

2.00+ Build 130305 released.

- Related Changesets
LimeSurvey: master 97a166e4
Timestamp: 2013-03-01 13:42:21
Author: c_schmitz
Committer: Carsten Schmitz
Details ] Diff ]
Fixed issue 07629: Fatal error on unexpected key/data when using RPC function add_response
mod - application/controllers/admin/remotecontrol.php Diff ] File ]
LimeSurvey: master 78f17a30
Timestamp: 2013-03-02 13:16:33
Author: c_schmitz
Committer: Carsten Schmitz
Details ] Diff ]
Fixed issue 07629: Fatal error on unexpected key/data when using RPC function add_response
mod - application/controllers/admin/remotecontrol.php Diff ] File ]
LimeSurvey: 2.1 fca41d2a
Timestamp: 2013-03-02 14:37:50
Author: c_schmitz
Committer: Carsten Schmitz
Details ] Diff ]
Fixed issue 07629: Fatal error on unexpected key/data when using RPC function add_response
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: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


Copyright © 2000 - 2014 MantisBT Team
Powered by Mantis Bugtracker