View Issue Details

This bug affects 1 person(s).
 14
IDProjectCategoryView StatusLast Update
18896Bug reportsQuestion editorpublic2024-08-30 15:07
Reportermferraz Assigned Toc_schmitz  
PrioritynoneSeveritypartial_block 
Status closedResolutionfixed 
Product Version6.1.x 
Summary18896: SQL: SQLSTATE[22P02]: Invalid Text Representation: 7 ERROR: Invalid Input Syntax when creating a survey
Description

Hi, I'm getting the following error on this installation. I've opted for PostgreSQL, and I'm getting the following when I try to create a new survey. The survey is created, but it's always generating the error. Getting the same when I activate the survey.SQL: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type integer: ""
LINE 1: ...LECT * FROM "lime_question_l10ns" "t" WHERE qid = '' and lan...
Thank you in advance.

PHP 8.2

Steps To Reproduce

Steps to reproduce

Create / Edit / Delete a survey with the Software versions described

Expected result

Manage a survey as expected

Actual result

Getting the error "7 ERROR: invalid input syntax for type integer"

TagsNo tags attached.
Bug heat14
Complete LimeSurvey version number (& build) 6.1.4+230620
I will donate to the project if issue is resolvedYes
Browser
Database type & versionPostgreSQL 13+225
Server OS (if known)
Webserver software & version (if known)
PHP Version8.2

Users monitoring this issue

mferraz

Activities

c_schmitz

c_schmitz

2023-06-20 15:33

administrator   ~75741

I cannot reproduce this at all, same version but with Postgres 15.

Can you enable debug = 2 in application/config/config.php and try again, please? Paste the complete error message here.

mferraz

mferraz

2023-06-20 15:36

reporter   ~75744

Hi.
Thank you for your reply.

Sure:

CDbException
CDbCommand falhou ao executar o comando SQL: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type integer: ""
LINE 1: ...LECT FROM "lime_question_l10ns" "t" WHERE qid = '' and lan...
^. The SQL statement executed was: SELECT
FROM "lime_question_l10ns" "t" WHERE qid = :qid and language = :language LIMIT 1

/opt/limesurvey/vendor/yiisoft/yii/framework/db/CDbCommand.php(543)

531 {
532 if($this->_connection->enableProfiling)
533 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');
534
535 $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
536 $message=$e->getMessage();
537 Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',
538 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
539
540 if(YII_DEBUG)
541 $message.='. The SQL statement executed was: '.$this->getText().$par;
542
543 throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
544 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
545 }
546 }
547
548 /*
549
Builds a SQL SELECT statement from the given query specification.
550 @param array $query the query specification in name-value pairs. The following
551
query options are supported: {@link select}, {@link distinct}, {@link from},
552 {@link where}, {@link join}, {@link group}, {@link having}, {@link order},
553
{@link limit}, {@link offset} and {@link union}.
554 @throws CDbException if "from" key is not present in given query parameter
555
@return string the SQL statement
Stack Trace
#0

  • /opt/limesurvey/vendor/yiisoft/yii/framework/db/CDbCommand.php(415): CDbCommand->queryInternal("fetch", array(2), array())
    #1
  • /opt/limesurvey/vendor/yiisoft/yii/framework/db/ar/CActiveRecord.php(1359): CDbCommand->queryRow()
    #2
    – /opt/limesurvey/application/models/LSActiveRecord.php(77): CActiveRecord->query(CDbCriteria, false)
    72 @since 1.1.7
    73
    /
    74 protected function query($criteria, $all = false, $asAR = true)
    75 {
    76 if ($asAR === true) {
    77 return parent::query($criteria, $all);
    78 } else {
    79 $this->beforeFind();
    80 $this->applyScopes($criteria);
    81 if (!$all) {
    82 $criteria->limit = 1;
    #3
  • /opt/limesurvey/vendor/yiisoft/yii/framework/db/ar/CActiveRecord.php(1464): LSActiveRecord->query(CDbCriteria)
    #4
    – /opt/limesurvey/application/core/plugins/expressionQuestionHelp/expressionQuestionHelp.php(47): CActiveRecord->find("qid = :qid and language = :language", array(":qid" => "", ":language" => "en"))
    42 {
    43 $knownVars = $this->event->get('knownVars');
    44 $language = $this->event->get('language');
    45 foreach ($knownVars as $var => $values) {
    46 if (isset($values['question']) && isset($values['qid'])) {
    47 $oQuestionL10n = QuestionL10n::model()->find('qid = :qid and language = :language', array(":qid" => $values['qid'],":language" => $language));
    48 if ($oQuestionL10n) {
    49 $knownVars[$var]['help'] = $oQuestionL10n->help;
    50 }
    51 }
    52 }
    #5
    unknown(0): expressionQuestionHelp->addQuestionHelp()
    #6
    – /opt/limesurvey/application/libraries/PluginManager/PluginManager.php(269): call_user_func(array(expressionQuestionHelp, "addQuestionHelp"))
    264 if (
    265 !$event->isStopped()
    266 && (empty($target) || in_array(get_class($subscription[0]), $target))
    267 ) {
    268 $subscription[0]->setEvent($event);
    269 call_user_func($subscription);
    270 }
    271 }
    272 }
    273
    274 return $event;
    #7
  • /opt/limesurvey/application/helpers/expressions/em_manager_helper.php(4002): LimeSurvey\PluginManager\PluginManager->dispatchEvent(LimeSurvey\PluginManager\PluginEvent)
    #8
  • /opt/limesurvey/application/helpers/expressions/em_manager_helper.php(4536): LimeExpressionManager->setVariableAndTokenMappingsForExpressionManager(122248)
    #9
  • /opt/limesurvey/application/controllers/QuestionAdministrationController.php(47): LimeExpressionManager::StartProcessingPage(false, true)
    #10
  • /opt/limesurvey/vendor/yiisoft/yii/framework/web/CController.php(783): QuestionAdministrationController->beforeRender("create")
    #11
  • /opt/limesurvey/application/controllers/QuestionAdministrationController.php(261): CController->render("create", array("oSurvey" => Survey, "oQuestion" => Question, "aQuestionTypeGroups" => array("perguntas_com_escolha_única" => array("questionGroupName" => "perguntas com escolha única", "questionTypes" => array(array("title" => "Botões Bootstrap", "name" => "bootstrap_buttons", "type" => "L", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Escolher entre 5 Pontos", "name" => "5pointchoice", "type" => "5", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Lista (Botões de opção)", "name" => "listradio", "type" => "L", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Lista com comentário", "name" => "list_with_comment", "type" => "O", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), ...)), "perguntas_de_escolha_múltipla" => array("questionGroupName" => "perguntas de escolha Múltipla", "questionTypes" => array(array("title" => "Botões Bootstrap", "name" => "bootstrap_buttons_multi", "type" => "M", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Escolha múltipla", "name" => "multiplechoice", "type" => "M", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Escolha múltipla com comentários", "name" => "multiplechoice_with_comments", "type" => "P", "detailpage" => " <div class="col-12 currentImageContainer"> ..."))), "perguntas_pré-definidas" => array("questionGroupName" => "Perguntas pré-definidas", "questionTypes" => array(array("title" => "Classificação", "name" => "ranking", "type" => "R", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Classificação avançada", "name" => "ranking_advanced", "type" => "R", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Data/Hora", "name" => "date", "type" => "D", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Entrada numérica", "name" => "numerical", "type" => "N", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), ...)), "perguntas_de_texto" => array("questionGroupName" => "perguntas de texto", "questionTypes" => array(array("title" => "Deteção do navegador", "name" => "browserdetect", "type" => "S", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Respostas à medida", "name" => "inputondemand", "type" => "Q", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Texto livre curto", "name" => "shortfreetext", "type" => "S", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), array("title" => "Texto livre longo", "name" => "longfreetext", "type" => "T", "detailpage" => " <div class="col-12 currentImageContainer"> ..."), ...)), ...), "advancedSettings" => array("Logic" => array(array("name" => "random_group", "caption" => "Randomization group name", "inputtype" => "text", "options" => null, ...), array("name" => "em_validation_q", "caption" => "Question validation equation", "inputtype" => "textarea", "options" => null, ...), array("name" => "em_validation_q_tip", "caption" => "Question validation tip", "inputtype" => "textarea", "options" => null, ...)), "Display" => array(array("name" => "hide_tip", "caption" => "Hide tip", "inputtype" => "switch", "options" => array("No", "Yes"), ...), array("name" => "text_input_width", "caption" => "Text input box width", "inputtype" => "singleselect", "options" => array("" => "Default", 1 => "8%", 2 => "17%", 3 => "25%", ...), ...), array("name" => "input_size", "caption" => "Text input box size", "inputtype" => "integer", "options" => null, ...), array("name" => "display_rows", "caption" => "Display rows", "inputtype" => "integer", "options" => null, ...), ...), "Input" => array(array("name" => "maximum_chars", "caption" => "Maximum characters", "inputtype" => "integer", "options" => null, ...)), "Other" => array(array("name" => "page_break", "caption" => "Insert page break in printable view", "inputtype" => "switch", "options" => array("No", "Yes"), ...)), ...), ...))
    #12
  • /opt/limesurvey/application/controllers/QuestionAdministrationController.php(150): QuestionAdministrationController->renderFormAux(Question)
    #13
  • /opt/limesurvey/application/controllers/QuestionAdministrationController.php(70): QuestionAdministrationController->actionEdit(19)
    #14
    unknown(0): QuestionAdministrationController->actionView("122248", "18", "19", "structure")
    #15
  • /opt/limesurvey/vendor/yiisoft/yii/framework/web/actions/CAction.php(115): ReflectionMethod->invokeArgs(QuestionAdministrationController, array("122248", "18", "19", "structure"))
    #16
  • /opt/limesurvey/vendor/yiisoft/yii/framework/web/actions/CInlineAction.php(47): CAction->runWithParamsInternal(QuestionAdministrationController, ReflectionMethod, array("surveyid" => "122248", "gid" => "18", "qid" => "19", "landOnSideMenuTab" => "structure"))
    #17
  • /opt/limesurvey/vendor/yiisoft/yii/framework/web/CController.php(308): CInlineAction->runWithParams(array("surveyid" => "122248", "gid" => "18", "qid" => "19", "landOnSideMenuTab" => "structure"))
    #18
  • /opt/limesurvey/vendor/yiisoft/yii/framework/web/CController.php(286): CController->runAction(CInlineAction)
    #19
  • /opt/limesurvey/vendor/yiisoft/yii/framework/web/CController.php(265): CController->runActionWithFilters(CInlineAction, array())
    #20
  • /opt/limesurvey/application/controllers/LSBaseController.php(145): CController->run("view")
    #21
  • /opt/limesurvey/vendor/yiisoft/yii/framework/web/CWebApplication.php(282): LSBaseController->run("view")
    #22
  • /opt/limesurvey/vendor/yiisoft/yii/framework/web/CWebApplication.php(141): CWebApplication->runController("questionAdministration/view")
    #23
  • /opt/limesurvey/vendor/yiisoft/yii/framework/base/CApplication.php(185): CWebApplication->processRequest()
    #24
  • /opt/limesurvey/index.php(161): CApplication->run()
    2023-06-20 14:35:01 Apache Yii Framework/1.1.28

I'm now using PHP 8.1 instead of 8.2 (but getting the same error).

c_schmitz

c_schmitz

2023-06-20 16:54

administrator   ~75747

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

LimeBot

LimeBot

2023-06-26 12:02

administrator   ~75853

Fixed in Release 6.1.5+230626

mferraz

mferraz

2024-01-03 18:27

reporter   ~79091

Hi, the problem seems to be back on Version 6.4.0+231218

image-1 (1).png (102,019 bytes)
mferraz

mferraz

2024-01-04 16:49

reporter   ~79093

Hi, the problem seems to be back on Version 6.4.0+231218

mferraz

mferraz

2024-01-09 14:36

reporter   ~79114

Hi.

Any update on this?
Still the same on the last update 6.4.1+240108

mferraz

mferraz

2024-01-12 16:38

reporter   ~79157

Hi.

Still the same issue, even with a new survey.

image.png (142,430 bytes)
mmilinovsky

mmilinovsky

2024-01-15 13:06

reporter   ~79164

The same here:
OS: Ubuntu 20.04.3 LTS
PostgreSQL: 14+238
PHP: 8.1+92ubuntu1
LimeSurvey: Community Edition Version 6.4.1+240108

mferraz

mferraz

2024-01-15 17:40

reporter   ~79169

ok, it's worse with the last update, we get the following right after login:

500: Internal Server Error CDbCommand failed to execute the SQL statement: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: boolean = integer
LINE 1: ...15 16:38:35' OR expires IS NULL) AND (user_status = 1)) AND ...
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.

ollehar

ollehar

2024-01-16 10:08

administrator   ~79173

This is a different error, I believe.

mferraz

mferraz

2024-01-16 10:14

reporter   ~79175

Hi, should I close this bug report and open a new one, or does a report for that already exist?
The error message is the same after creating a new survey, and now with the release 6.4.2+240115 after login.

Thank you for your reply.

thegcat

thegcat

2024-02-10 23:39

reporter   ~79442

We can confirm the issue described in comments 18896:79091 and 18896:79157. We are using Limesurvey 6.4.3, though looking a the current master code on GitHub doesn't make me hopeful this is fixed.

We can however provide a scenario to reproduce this. Adding a subquestion triggers this error, though starting only with the second subquestion.

I think what triggers this is generating a random question id in https://github.com/LimeSurvey/LimeSurvey/blob/master/application/controllers/QuestionAdministrationController.php#L722 and then trying to get a question object for this is https://github.com/LimeSurvey/LimeSurvey/blob/master/application/controllers/QuestionAdministrationController.php#L830. MySQL doesn't care a bit about any garbage it is passed (at least in the default settings) and will happily accept new12345 as an ID to search a question with (and I think it will just drop the new part because it's not a number and keep 12345, but that's another issue), whereas PostgreSQL loudly fails when passed a string value for an integer field (new12345 for qid).

Most astonishing is that in that case at least the random issue is called to get an empty subquestion object with https://github.com/LimeSurvey/LimeSurvey/blob/master/application/models/Question.php#L1654, which doesn't seem to care at all about any attribute from the object it is called from, though I am not a php developer and might be missing something.

I hope this analysis will help bring a resolution for this issue forward.

mmilinovsky

mmilinovsky

2024-02-16 11:22

reporter   ~79535

I can confirm, that with version 6.4.6 the bug has gone in our installation.

thegcat

thegcat

2024-02-16 12:15

reporter   ~79536

We are on version 6.4.5 and this problem does not happen anymore.

Related Changesets

LimeSurvey: master 2e4e644d

2023-06-20 18:54

c_schmitz


Details Diff
Fixed issue 18896: Error on Postgres when creating a survey and expressionQuestionHelp plugins is activated Affected Issues
18896
mod - application/core/plugins/expressionQuestionHelp/expressionQuestionHelp.php Diff File

Issue History

Date Modified Username Field Change
2023-06-20 12:10 mferraz New Issue
2023-06-20 12:11 mferraz Issue Monitored: mferraz
2023-06-20 12:11 mferraz Bug heat 0 => 2
2023-06-20 15:24 c_schmitz Assigned To => c_schmitz
2023-06-20 15:24 c_schmitz Status new => assigned
2023-06-20 15:33 c_schmitz Status assigned => feedback
2023-06-20 15:33 c_schmitz Note Added: 75741
2023-06-20 15:33 c_schmitz Bug heat 2 => 4
2023-06-20 15:36 mferraz Note Added: 75744
2023-06-20 15:36 mferraz Bug heat 4 => 6
2023-06-20 15:36 mferraz Status feedback => assigned
2023-06-20 16:54 c_schmitz Changeset attached => LimeSurvey master 2e4e644d
2023-06-20 16:54 c_schmitz Note Added: 75747
2023-06-20 16:54 c_schmitz Resolution open => fixed
2023-06-20 16:54 c_schmitz Status assigned => resolved
2023-06-26 12:02 LimeBot Note Added: 75853
2023-06-26 12:02 LimeBot Status resolved => closed
2023-06-26 12:02 LimeBot Bug heat 6 => 8
2024-01-03 18:27 mferraz Note Added: 79091
2024-01-03 18:27 mferraz File Added: image-1 (1).png
2024-01-04 16:49 mferraz Status closed => feedback
2024-01-04 16:49 mferraz Resolution fixed => reopened
2024-01-04 16:49 mferraz Note Added: 79093
2024-01-09 14:36 mferraz Note Added: 79114
2024-01-09 14:36 mferraz Status feedback => assigned
2024-01-12 16:38 mferraz Note Added: 79157
2024-01-12 16:38 mferraz File Added: image.png
2024-01-15 13:06 mmilinovsky Note Added: 79164
2024-01-15 13:06 mmilinovsky Bug heat 8 => 10
2024-01-15 17:40 mferraz Note Added: 79169
2024-01-16 10:08 ollehar Note Added: 79173
2024-01-16 10:08 ollehar Bug heat 10 => 12
2024-01-16 10:14 mferraz Note Added: 79175
2024-01-29 09:03 mmilinovsky Issue Monitored: mmilinovsky
2024-01-29 09:03 mmilinovsky Bug heat 12 => 14
2024-02-10 23:39 thegcat Note Added: 79442
2024-02-10 23:39 thegcat Bug heat 14 => 16
2024-02-16 11:22 mmilinovsky Note Added: 79535
2024-02-16 11:23 mmilinovsky Issue End Monitor: mmilinovsky
2024-02-16 11:23 mmilinovsky Bug heat 16 => 14
2024-02-16 12:15 thegcat Note Added: 79536
2024-02-19 14:04 c_schmitz Status assigned => resolved
2024-02-19 14:04 c_schmitz Resolution reopened => fixed
2024-08-30 15:07 c_schmitz Status resolved => closed