View Issue Details

IDProjectCategoryView StatusLast Update
15651Bug reports[All Projects] RemoteControlpublic2020-01-17 01:22
Reporterandre_ars Assigned Toadamzammit  
PrioritynoneSeveritymajor 
Status assignedResolutionfixed 
Product Version4.0.0-RC8 
Target VersionFixed in Version 
Summary15651: delete_participant fails to delete and gives no error back
Description

When trying to delete participants using RPC, i get an empty array back along with error = null.

My post:
{"method":"delete_participants","params":["xxxxxxxxxxxxxxxxxxxxxxxxxxx","884387",["120"]],"id":1}
this works in 3.14
I've tested to the 3.20.2 and 4.0.8 all with the same error:
a) It doesn't get back a response
b) Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 1' at line 1

Steps To Reproduce

{"method":"delete_participants","params":["xxxxxxxxxxxxxxxxxxxxxxxxxxx","884387",["120"]],"id":1}

TagsNo tags attached.
Complete LimeSurvey version number (& build)4.0.0-RC9+191125 && all before util 3.14
I will donate to the project if issue is resolvedYes
BrowserFirefox
Database & DB-VersionMariaDB 10.2
Server OS (if known)Centos
Webserver software & version (if known)apache
PHP Version7.2

Relationships

related to 14601 assignedcdorin AutitLog : RemoteControl delete_participant tries to execute invalid SQL 

Activities

adamzammit

adamzammit

2019-12-11 04:45

developer   ~54996

Hi Andre,

I have tested 4.0.0-rc11 and 3.21.1 both clean installations in Docker images using the following remote testing code and it worked fine for me:

<?php

include('JsonRPCClient.php');

$c = new org\jsonrpcphp\JsonRPCClient("http://localhost:8082/admin/remotecontrol&quot;);

$key = $c->get_session_key("admin","password");

$limeid = 584128;

//$r = $c->export_timeline($key,'335619','hour','2016-01-01','2018-01-01');

$dtoken = "QUEXSTESTTOKEN";
$np = $c->add_participants($key,$limeid,array(array('firstname'=>$dtoken,'lastname'=>$dtoken)));

var_dump($np);

if (isset($np[0]['tid'])) {
  $ret = array_keys($np[0]); //array of data
var_dump($ret);
 $r = $c->delete_participants($key,$limeid,array($np[0]['tid']));
}

var_dump($r);

$c->release_session_key($key);
?>

I also tested this same code on 3.15.1 (using: docker pull acspri/limesurvey:3.15.1 ) and it worked too.

adamzammit

adamzammit

2020-01-07 01:50

developer   ~55136

Hi again Andre,

I ran into this problem again and was able to resolve it by changing the following code in helpers/remotecontrol/remotecontrol_handler.php:

replace (around line 1802):

            $aResult = array();
            foreach ($aTokenIDs as $iTokenID) {
                $iTokenID = (int) $iTokenID;
                $token = Token::model($iSurveyID)->findByPk($iTokenID);
                if (!isset($token)) {
                                        $aResult[$iTokenID] = 'Invalid token ID';
                } elseif ($token->delete()) {
                                        $aResult[$iTokenID] = 'Deleted';
                } else {
                                        $aResult[$iTokenID] = 'Deletion went wrong';
                }
            }
            return $aResult;

with:

            foreach ($aTokenIDs as $iTokenID) {
                $iTokenID = (int) $iTokenID;
                $token = Token::model($iSurveyID)->findByPk($iTokenID);
                if (!isset($token)) {
                                        $aResult[$iTokenID] = 'Invalid token ID';
                } else {
                                        $iDel = Token::model($iSurveyID)->deleteByPk($iTokenID);
                                        if ($iDel > 0) {
                                            $aResult[$iTokenID] = 'Deleted';
                                        } else {
                                            $aResult[$iTokenID] = 'Deletion went wrong';
                                        }
                }
            }
            return $aResult;

I couldn't work out the reason why, but somehow when getting the record $token, the record was visible and available, but then when calling $token->delete it caused an SQL error that looked like this:

PHP Fatal error: Uncaught Exception: Request error: CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1. The SQL statement executed was: SELECT * FROM lsrx_tokens_737958 t WHERE tid= LIMIT 1

So it wasn't filling in the tid value...

I couldn't work out why this was happening sometimes but the code above seems to resolve it.

Adam

adamzammit

adamzammit

2020-01-07 02:00

developer   ~55137

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

ginosupport

ginosupport

2020-01-14 15:32

reporter   ~55237

Does this also fix https://bugs.limesurvey.org/view.php?id=14601?

adamzammit

adamzammit

2020-01-17 01:22

developer   ~55341

It should - can you please confirm @ginosupport?

Related Changesets

LimeSurvey: master e39cfb14

2020-01-07 01:58:20

adamzammit

Details Diff
Fixed issue 15651: delete_participant fails to delete and gives no error back Affected Issues
15651
mod - application/helpers/remotecontrol/remotecontrol_handle.php Diff File

Issue History

Date Modified Username Field Change
2019-12-09 15:53 andre_ars New Issue
2019-12-11 04:45 adamzammit Note Added: 54996
2019-12-15 21:49 cdorin Assigned To => cdorin
2019-12-15 21:49 cdorin Status new => assigned
2020-01-07 01:50 adamzammit Note Added: 55136
2020-01-07 02:00 adamzammit Changeset attached => LimeSurvey master e39cfb14
2020-01-07 02:00 adamzammit Note Added: 55137
2020-01-07 02:00 adamzammit Assigned To cdorin => adamzammit
2020-01-07 02:00 adamzammit Resolution open => fixed
2020-01-14 15:32 ginosupport Note Added: 55237
2020-01-17 01:21 adamzammit Relationship added related to 14601
2020-01-17 01:22 adamzammit Note Added: 55341