View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 19479 | Bug reports | Central participant database | public | 2024-03-13 16:55 | 2024-03-13 16:55 |
| Reporter | vpupillo | Assigned To | |||
| Priority | none | Severity | partial_block | ||
| Status | new | Resolution | open | ||
| Product Version | 6.4.x | ||||
| Summary | 19479: internal server error when upload csv with "overwrite" | ||||
| Description | Hi, patch attached. | ||||
| Steps To Reproduce | Steps to reproducewith a clean CPDB, add some attributes (we have 6 attributes).
Expected resultno internal server errors and cpdb updated. Actual result(Write here what happened instead) | ||||
| Tags | No tags attached. | ||||
| Attached Files | 0001-check-if-Participant-has-a-property-before-save-it-i.patch (1,869 bytes)
From c732e5d5b863efbddf845eacd74a6e1d70108ac5 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Wed, 13 Mar 2024 15:35:12 +0100
Subject: [PATCH] check if Participant has a property before save it into the
CPDB.
---
application/controllers/admin/ParticipantsAction.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/application/controllers/admin/ParticipantsAction.php b/application/controllers/admin/ParticipantsAction.php
index 76801e7c1c..254430eb7d 100644
--- a/application/controllers/admin/ParticipantsAction.php
+++ b/application/controllers/admin/ParticipantsAction.php
@@ -947,6 +947,10 @@ class ParticipantsAction extends SurveyCommonAction
array_push($allowedfieldnames, strtolower((string) $value));
}
}
+
+ // initialize loop variable
+ $firstline = array();
+ $ignoredcolumns = array();
foreach ($tokenlistarray as $buffer) {
//Iterate through the CSV file line by line
$buffer = @mb_convert_encoding((string) $buffer, "UTF-8", $uploadcharset);
@@ -1034,7 +1038,10 @@ class ParticipantsAction extends SurveyCommonAction
if (in_array($attribute, ['firstname', 'lastname', 'email'])) {
continue;
}
- $oParticipant->$attribute = $value;
+ // check if a property exist before update it
+ if (property_exists($oParticipant, $attribute)) {
+ $oParticipant->$attribute = $value;
+ }
}
$oParticipant->save();
//Although this person already exists, we want to update the mapped attribute values
--
2.44.0
| ||||
| Bug heat | 0 | ||||
| Complete LimeSurvey version number (& build) | 6.4.12-240311 | ||||
| I will donate to the project if issue is resolved | No | ||||
| Browser | |||||
| Database type & version | MariaDB 10.5.23 | ||||
| Server OS (if known) | |||||
| Webserver software & version (if known) | |||||
| PHP Version | PHP 8.1.2 and 8.2.16 | ||||