View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
12055Bug reportsConditionspublic2017-02-21 11:56
Reporterintavg Assigned Toc_schmitz  
PrioritynoneSeveritypartial_block 
Status closedResolutionfixed 
Product Version2.58.x 
Fixed in Version2.62.x 
Summary12055: Error when setting conditions on questions
Description

Using a SQL Server 2014 database, get a database error when saving conditions for a question. When the condition is based on a gender question, the answer never displays. Having the issue since 2.55.

Steps To Reproduce

Create a gender question, a yes/no question and a text question. Create a condition on the text question using the Female answer from the gender question. You will get the error below, and the question will not display regardless of the answer to the gender question.

Create a condition on the text question using the yes answer of the yes/no question. You will get an error similar to below, but when executing the survey the question will be displayed when answering yes to the yes/no question.

Additional Information

CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[07002]: [Microsoft][ODBC Driver 11 for SQL Server]COUNT field incorrect or syntax error. The SQL statement executed was: SELECT count(*) as recordcount
FROM lime_conditions c, lime_questions q, lime_groups g
WHERE c.cqid=q.qid AND q.gid=g.gid AND q.parent_qid=0 AND q.language=:lang AND g.language=:lang AND c.qid=:qid AND c.scenario=:scenario AND c.cfieldname NOT LIKE '{%' . Bound with :scenario='1', :qid='2232', :lang='en'

D:\inetpub\wwwroot\survey\src\s\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
+
D:\inetpub\wwwroot\survey\src\s\framework\db\CDbCommand.php(415): CDbCommand->queryInternal("fetch", array(2), array())
#1

D:\inetpub\wwwroot\survey\src\s\application\models\Condition.php(229): CDbCommand->queryRow()

224 ."AND c.cfieldname NOT LIKE '{%' "; // avoid catching SRCtokenAttr conditions
225 $result=Yii::app()->db->createCommand($query)
226 ->bindValue(":scenario", $scenarionr['scenario'])
227 ->bindValue(":qid", $qid, PDO::PARAM_INT)
228 ->bindValue(":lang", $language, PDO::PARAM_STR)
229 ->queryRow();
230 return (int) $result['recordcount'];
231 }
232
233 /*
234
@param int $qid

#2

D:\inetpub\wwwroot\survey\src\s\application\controllers\admin\conditionsaction.php(414): Condition->getConditionCount("2232", "en", Condition)

409 */
410 $aData['conditionHtml'] = '';
411
412 unset($currentfield);
413
414 $conditionscount = Condition::model()->getConditionCount($qid, $this->language, $scenarionr);
415 $conditions = Condition::model()->getConditions($qid, $this->language, $scenarionr);
416 $conditionscounttoken = Condition::model()->getConditionCountToken($qid, $scenarionr);
417 $resulttoken = Condition::model()->getConditionsToken($qid, $scenarionr);
418
419 $conditionscount = $conditionscount + $conditionscounttoken;

#3
unknown(0): conditionsaction->index("editconditionsform", "999999", "116", "2232")
#4
+
D:\inetpub\wwwroot\survey\src\s\framework\web\actions\CAction.php(109): ReflectionMethod->invokeArgs(conditionsaction, array("editconditionsform", "999999", "116", "2232"))
#5

D:\inetpub\wwwroot\survey\src\s\application\core\Survey_Common_Action.php(101): CAction->runWithParamsInternal(conditionsaction, ReflectionMethod, array("r" => "admin/conditions/sa/index/subaction/editconditionsform/surveyid/...", "sa" => "index", "subaction" => "editconditionsform", "surveyid" => "999999", ...))

096 $oMethod = new ReflectionMethod($this, $sDefault);
097 }
098
099 // We're all good to go, let's execute it
100 // runWithParamsInternal would automatically get the parameters of the method and populate them as required with the params
101 return parent::runWithParamsInternal($this, $oMethod, $params);
102 }
103
104 /*
105
Some functions have different parameters, which are just an alias of the
106 * usual parameters we're getting in the url. This function just populates

#6
+
D:\inetpub\wwwroot\survey\src\s\framework\web\CController.php(308): Survey_Common_Action->runWithParams(array("r" => "admin/conditions/sa/index/subaction/editconditionsform/surveyid/...", "sa" => "index", "subaction" => "editconditionsform", "surveyid" => "999999", ...))
#7
+
D:\inetpub\wwwroot\survey\src\s\framework\web\CController.php(286): CController->runAction(conditionsaction)
#8
+
D:\inetpub\wwwroot\survey\src\s\framework\web\CController.php(265): CController->runActionWithFilters(conditionsaction, array())
#9
+
D:\inetpub\wwwroot\survey\src\s\application\controllers\AdminController.php(177): CController->run("conditions")
#10
+
D:\inetpub\wwwroot\survey\src\s\framework\web\CWebApplication.php(282): AdminController->run("conditions")
#11
+
D:\inetpub\wwwroot\survey\src\s\framework\web\CWebApplication.php(141): CWebApplication->runController("admin/conditions/sa/index/subaction/editconditionsform/surveyid/...")
#12
+
D:\inetpub\wwwroot\survey\src\s\framework\base\CApplication.php(185): CWebApplication->processRequest()
#13
+
D:\inetpub\wwwroot\survey\src\s\index.php(214): CApplication->run()
2017-01-12 15:06:15 Microsoft-IIS/8.5 Yii Framework/1.1.17

TagsNo tags attached.
Attached Files
Bug heat6
Complete LimeSurvey version number (& build)2.58.2+170114
I will donate to the project if issue is resolvedNo
BrowserTested Firefox and Chrome
Database type & versionSQL Server 2014
Server OS (if known)Windows 2012
Webserver software & version (if known)IIS 8.5
PHP Version5.6.24

Users monitoring this issue

There are no users monitoring this issue.

Activities

ollehar

ollehar

2017-01-13 10:26

administrator   ~42709

Screenshot on the error, and conditions?

brmi0019

brmi0019

2017-01-27 14:47

reporter   ~42852

same error in:
Version 2.62.0+170124
SQL Server 2012
PHP 5.6.27

Solution: the binding parameters must have unique names even if they have the same value

count(*) as recordcount
FROM lime_conditions c, lime_questions q, lime_groups g
WHERE c.cqid=q.qid AND q.gid=g.gid AND q.parent_qid=0 AND q.language=:lang1 AND g.language=:lang2 AND c.qid=:qid AND c.scenario=:scenario AND c.cfieldname NOT LIKE '{%' . Bound with :scenario='1', :qid='2232', :lang1='en', :lang2='en'

brmi0019

brmi0019

2017-01-30 09:01

reporter   ~42861

additional information:
In my case the error occures if I click the "Set conditions" button on the "Question summary" page of a question with "Relevance equation:" e.g.:((A0.NAOK == "A2"))
A question without "Relevance equation:" will load the "Conditions designer" page.
=> see screenshots

c_schmitz

c_schmitz

2017-01-31 14:12

administrator   ~42906

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

c_schmitz

c_schmitz

2017-01-31 14:12

administrator   ~42907

Thank you!

Related Changesets

LimeSurvey: master 2a34e3ac

2017-01-31 14:11:45

c_schmitz

Details Diff
Fixed issue 12055: Error when setting conditions on questions Affected Issues
12055
mod - application/models/Condition.php Diff File

Issue History

Date Modified Username Field Change
2017-01-12 21:10 intavg New Issue
2017-01-13 10:26 ollehar Note Added: 42709
2017-01-27 14:47 brmi0019 Note Added: 42852
2017-01-30 09:01 brmi0019 File Added: Limesurvey_error_20170130.png
2017-01-30 09:01 brmi0019 Note Added: 42861
2017-01-31 14:12 c_schmitz Changeset attached => LimeSurvey master 2a34e3ac
2017-01-31 14:12 c_schmitz Note Added: 42906
2017-01-31 14:12 c_schmitz Assigned To => c_schmitz
2017-01-31 14:12 c_schmitz Resolution open => fixed
2017-01-31 14:12 c_schmitz Status new => resolved
2017-01-31 14:12 c_schmitz Fixed in Version => 2.62.x
2017-01-31 14:12 c_schmitz Note Added: 42907
2017-02-21 11:56 c_schmitz Status resolved => closed