View Issue Details

This bug affects 1 person(s).
 0
IDProjectCategoryView StatusLast Update
19479Bug reportsCentral participant databasepublic2024-03-13 16:55
Reportervpupillo Assigned To 
PrioritynoneSeveritypartial_block 
Status newResolutionopen 
Product Version6.4.x 
Summary19479: internal server error when upload csv with "overwrite"
Description

Hi,
we have many attributes linked to our participants in the CPDB.
When we try to load an update of this data, overwriting it, Limesurvey generates an internal server error.
Limesurvey tries to store a value of "participant_attributes" in the "participants" table.

patch attached.
Thaks

Steps To Reproduce

Steps to reproduce

with a clean CPDB, add some attributes (we have 6 attributes).

  1. upload a CSV (mapping the CSV attributes)
  2. Edit some CSV data
  3. Load the updated file in overwrite mode.

Expected result

no internal server errors and cpdb updated.

Actual result

(Write here what happened instead)

TagsNo 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 heat0
Complete LimeSurvey version number (& build)6.4.12-240311
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMariaDB 10.5.23
Server OS (if known)
Webserver software & version (if known)
PHP VersionPHP 8.1.2 and 8.2.16

Users monitoring this issue

There are no users monitoring this issue.

Activities

Issue History

Date Modified Username Field Change
2024-03-13 16:55 vpupillo New Issue
2024-03-13 16:55 vpupillo File Added: 0001-check-if-Participant-has-a-property-before-save-it-i.patch