From db693f74bbc7e9c1fcb2b26e663a3c4b02208fec Mon Sep 17 00:00:00 2001 From: GabrielJenik Date: Tue, 29 Dec 2020 12:21:11 -0300 Subject: [PATCH 1/2] Fixed issue #16474: Remote control import_group broken Fixed and Added test case --- .../remotecontrol/remotecontrol_handle.php | 2 +- tests/TestHelper.php | 2 +- .../data/file_upload/limesurvey_group_472.lsg | 530 ++++++++++++++++++ .../limesurvey_survey_251297_import_group.lss | 294 ++++++++++ tests/unit/helpers/RemoteControlTest.php | 62 ++ 5 files changed, 888 insertions(+), 2 deletions(-) create mode 100644 tests/data/file_upload/limesurvey_group_472.lsg create mode 100644 tests/data/surveys/limesurvey_survey_251297_import_group.lss diff --git a/application/helpers/remotecontrol/remotecontrol_handle.php b/application/helpers/remotecontrol/remotecontrol_handle.php index 15d94f55ffa..287fc8f8948 100644 --- a/application/helpers/remotecontrol/remotecontrol_handle.php +++ b/application/helpers/remotecontrol/remotecontrol_handle.php @@ -1123,7 +1123,7 @@ public function import_group($sSessionKey, $iSurveyID, $sImportData, $sImportDat libxml_disable_entity_loader($bOldEntityLoaderState); // Put back entity loader to its original state, to avoid contagion to other applications on the server return array('status' => 'Error: Invalid LimeSurvey group structure XML '); } - $aImportResults = XMLImportGroup($sFullFilePath, $iSurveyID); + $aImportResults = XMLImportGroup($sFullFilePath, $iSurveyID, true); } else { return array('status' => 'Invalid extension'); } diff --git a/tests/TestHelper.php b/tests/TestHelper.php index 896d17a7c56..cb2eaf70c0f 100644 --- a/tests/TestHelper.php +++ b/tests/TestHelper.php @@ -26,7 +26,7 @@ public function importAll() \Yii::import('application.helpers.common_helper', true); \Yii::import('application.helpers.replacements_helper', true); \Yii::import('application.helpers.surveytranslator_helper', true); - \Yii::import('application.helpers.admin.import_helper', true); + \Yii::app()->loadHelper('admin/import'); \Yii::import('application.helpers.expressions.em_manager_helper', true); \Yii::import('application.helpers.expressions.em_manager_helper', true); \Yii::import('application.helpers.qanda_helper', true); diff --git a/tests/data/file_upload/limesurvey_group_472.lsg b/tests/data/file_upload/limesurvey_group_472.lsg new file mode 100644 index 00000000000..3544bf2b43e --- /dev/null +++ b/tests/data/file_upload/limesurvey_group_472.lsg @@ -0,0 +1,530 @@ + + + Group + 435 + + en + + + + gid + sid + group_order + randomization_group + grelevance + + + + + + + + + + + + + + id + gid + group_name + description + language + sid + group_order + randomization_group + grelevance + + + + + + + This is an imported group

]]>
+ + + + + +
+
+
+ + + qid + parent_qid + sid + gid + type + title + preg + other + mandatory + question_order + scale_id + same_default + relevance + modulename + encrypted + + + + + + + + + <![CDATA[Q01]]> + + + + + + + + + + + + + + + + + <![CDATA[Q02]]> + + + + + + + + + + + + + + + id + qid + question + help + language + script + + + + + + First question

]]>
+ + +