View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
20097Bug reportsSurvey takingpublic2025-05-20 14:06
Reportergabrieljenik Assigned Totibor.pacalat  
PrioritynoneSeveritypartial_block 
Status closedResolutionfixed 
Product Version6.4.x 
Summary20097: SQL Error when saving failed email notifications
Description

When:

  • enabling admin notifications
  • and an error happens when sending notification,
  • a record is attempted to be saved to lime_failed_emails

Fails with this error:

CDbException
CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF2\x00H[\x185...' for column `sample_ls5`.`lime_failed_emails`.`error_message` at row 1. The SQL statement executed was: INSERT INTO `lime_failed_emails` (`language`, `status`, `recipient`, `surveyid`, `responseid`, `email_type`, `error_message`, `created`, `updated`, `resend_vars`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, NOW(), :yp7, :yp8)
/home/sample/public_html/vendor/yiisoft/yii/framework/db/CDbCommand.php(358)
346         {
347             if($this->_connection->enableProfiling)
348                 Yii::endProfile('system.db.CDbCommand.execute('.$this->getText().$par.')','system.db.CDbCommand.execute');
349 
350             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
351             $message=$e->getMessage();
352             Yii::log(Yii::t('yii','CDbCommand::execute() failed: {error}. The SQL statement executed was: {sql}.',
353                 array('{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
354 
355             if(YII_DEBUG)
356                 $message.='. The SQL statement executed was: '.$this->getText().$par;
357 
358             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
359                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
360         }
361     }
362 
363     /**
364      * Executes the SQL statement and returns query result.
365      * This method is for executing an SQL query that returns result set.
366      * @param array $params input parameters (name=>value) for the SQL execution. This is an alternative
367      * to {@link bindParam} and {@link bindValue}. If you have multiple input parameters, passing
368      * them in this way can improve the performance. Note that if you pass parameters in this way,
369      * you cannot bind parameters or values using {@link bindParam} or {@link bindValue}, and vice versa.
370      * Please also note that all values are treated as strings in this case, if you need them to be handled as
Stack Trace
#0
+  /home/sample/public_html/vendor/yiisoft/yii/framework/db/ar/CActiveRecord.php(1083): CDbCommand->execute()
#1
+  /home/sample/public_html/vendor/yiisoft/yii/framework/db/ar/CActiveRecord.php(811): CActiveRecord->insert(null)
#2
–  /home/sample/public_html/application/helpers/frontend_helper.php(699): CActiveRecord->save(false)
694     $failedEmailModel->created = date('Y-m-d H:i:s');
695     $failedEmailModel->status = 'SEND FAILED';
696     $failedEmailModel->updated = date('Y-m-d H:i:s');
697     $failedEmailModel->resend_vars = $resendVars;
698 
699     return $failedEmailModel->save(false);
700 }
701 
702 function failedEmailSuccess($id)
703 {
704     $model = new FailedEmail();
#3
–  /home/sample/public_html/application/helpers/frontend_helper.php(550): saveFailedEmail(null, "xxxx@example.com", 616768, 1001, ...)
545                 $mailer->setTo($notificationRecipient);
546                 $mailerSuccess = $mailer->SendMessage();
547             }
548             if (!$mailerSuccess) {
549                 $failedEmailCount++;
550                 saveFailedEmail($failedNotificationId, $notificationRecipient, $surveyid, $responseId, 'admin_notification', $emailLanguage, $mailer);
551                 if (empty($emails) && $debug > 0 && Permission::model()->hasSurveyPermission($surveyid, 'surveysettings', 'update')) {
552                     /* Find a better way to show email error … */
553                     echo CHtml::tag(
554                         "div",
555                         ['class' => 'alert alert-danger'],
#4
–  /home/sample/public_html/application/helpers/SurveyRuntimeHelper.php(1271): sendSubmitNotifications(616768)
1266             if ($surveyActive && $oSurvey->getHasTokensTable()) {
1267                 submittokens();
1268             }
1269             //Send notifications
1270             if ($surveyActive) {
1271                 sendSubmitNotifications($this->iSurveyid);
1272             }
1273             // Link to Print Answer Preview  **********
1274             $this->aSurveyInfo['aCompleted']['aPrintAnswers']['show'] = false;
1275             if ($this->aSurveyInfo['printanswers'] == 'Y') {
1276                 $this->aSurveyInfo['aCompleted']['aPrintAnswers']['show']  = true;
#5
+  /home/sample/public_html/application/helpers/SurveyRuntimeHelper.php(219): SurveyRuntimeHelper->moveSubmitIfNeeded()
#6
+  /home/sample/public_html/application/controllers/survey/SurveyIndex.php(643): SurveyRuntimeHelper->run(616768, array("surveyid" => 616768, "thissurvey" => array("sid" => 616768, "owner_id" => 5, "gsid" => 1, "admin" => "Administrator", ...), "thisstep" => 6, "tokensexist" => 0, ...))
#7
+  /home/sample/public_html/application/controllers/survey/SurveyIndex.php(22): SurveyIndex->action()
#8
+  /home/sample/public_html/vendor/yiisoft/yii/framework/web/actions/CAction.php(76): SurveyIndex->run()
#9
+  /home/sample/public_html/vendor/yiisoft/yii/framework/web/CController.php(308): CAction->runWithParams(array("sid" => "616768"))
#10
+  /home/sample/public_html/vendor/yiisoft/yii/framework/web/CController.php(286): CController->runAction(SurveyIndex)
#11
+  /home/sample/public_html/vendor/yiisoft/yii/framework/web/CController.php(265): CController->runActionWithFilters(SurveyIndex, array())
#12
+  /home/sample/public_html/vendor/yiisoft/yii/framework/web/CWebApplication.php(282): CController->run("index")
#13
+  /home/sample/public_html/vendor/yiisoft/yii/framework/web/CWebApplication.php(141): CWebApplication->runController("survey/index/sid/616768")
#14
+  /home/sample/public_html/vendor/yiisoft/yii/framework/base/CApplication.php(185): CWebApplication->processRequest()
#15
+  /home/sample/public_html/index.php(161): CApplication->run()
Steps To Reproduce

Hard to reproduce without tampering the code or credentials, as hard to trigger an email sending error

Additional Information

ChatGPT said it could be an issue with a character not matching the expected encoding.

TagsNo tags attached.
Bug heat6
Complete LimeSurvey version number (& build)6.4
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMysql
Server OS (if known)
Webserver software & version (if known)
PHP Version8

Users monitoring this issue

There are no users monitoring this issue.

Activities

gabrieljenik

gabrieljenik

2025-05-15 21:05

manager   ~82681

https://github.com/LimeSurvey/LimeSurvey/pull/4281

guest

guest

2025-05-16 17:23

viewer   ~82695

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

LimeBot

LimeBot

2025-05-20 14:06

administrator   ~82716

Fixed in Release 6.14.0+250520

Related Changesets

LimeSurvey: master d98ac393

2025-05-16 17:23

Gabriel Jenik

Committer: GitHub


Details Diff
Fixed issue 20097: SQL Error when saving failed email notification (04281)

Co-authored-by: lapiudevgit <devgit@lapiu.biz>
Affected Issues
20097
mod - application/helpers/frontend_helper.php Diff File

Issue History

Date Modified Username Field Change
2025-05-08 14:13 gabrieljenik New Issue
2025-05-08 14:15 gabrieljenik Description Updated
2025-05-08 14:15 gabrieljenik Additional Information Updated
2025-05-08 14:33 tibor.pacalat Assigned To => gabrieljenik
2025-05-08 14:33 tibor.pacalat Status new => assigned
2025-05-15 18:41 gabrieljenik Description Updated
2025-05-15 21:05 gabrieljenik Assigned To gabrieljenik => DenisChenu
2025-05-15 21:05 gabrieljenik Status assigned => ready for code review
2025-05-15 21:05 gabrieljenik Note Added: 82681
2025-05-15 21:05 gabrieljenik Bug heat 0 => 2
2025-05-16 08:15 DenisChenu Assigned To DenisChenu => tibor.pacalat
2025-05-16 08:15 DenisChenu Status ready for code review => ready for testing
2025-05-16 17:23 Changeset attached => LimeSurvey master d98ac393
2025-05-16 17:23 guest Note Added: 82695
2025-05-16 17:23 guest Bug heat 2 => 4
2025-05-16 17:23 tibor.pacalat Status ready for testing => resolved
2025-05-16 17:23 tibor.pacalat Resolution open => fixed
2025-05-20 14:06 LimeBot Note Added: 82716
2025-05-20 14:06 LimeBot Status resolved => closed
2025-05-20 14:06 LimeBot Bug heat 4 => 6