View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
06138Bug reportsSurvey participants (Tokens)public2012-07-19 23:34
Reporteradoubleu Assigned ToDenisChenu  
PrioritynormalSeverityblock 
Status closedResolutionfixed 
Product Version2.00RC1 
Fixed in Version2.00RC5 
Summary06138: Undefined index: count(tid) in Tokens_dynamic.php(85)
Description

Undefined index: count(tid), see attachement for details of php output

Steps To Reproduce

Install YII version from git such as described in http://docs.limesurvey.org/Accessing+the+source+code&structure=LimeSurvey+development

  • use installer such as described in docs/readme.txt
  • install with postgres db
  • create a survey with any content
  • initialize tokens
  • token db will be created, but following tasks for showing tokens fails, i.e. url is <host>/index.php/admin/tokens/index/surveyid/<surveyID>
TagsNo tags attached.
Attached Files
phpNotice.pdf (574,918 bytes)
Bug heat4
Complete LimeSurvey version number (& build)1
I will donate to the project if issue is resolvedNo
Browserany
Database type & versionpostgres 9
Server OS (if known)ubuntu
Webserver software & version (if known)apache 2.2
PHP Version5.3

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2012-05-30 16:43

developer   ~19003

Fix committed to Yii branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=8580

c_schmitz

c_schmitz

2012-06-20 14:05

administrator   ~19379

2.0RC3 released

c_schmitz

c_schmitz

2012-06-21 13:46

administrator   ~19437

Can you please have another look at this. You seems have implemented DB type specific SQL and completely breaking MSSQL (and maybe Postgres).

DenisChenu

DenisChenu

2012-06-21 14:48

developer   ~19443

Last edited: 2012-06-21 14:48

Zut,

I have a look at http://weblogs.asp.net/wilczynski/archive/2008/06/03/sum-case-in-sql.aspx before put this patch.

Use the old method then.

(and tested with pgsql)

DenisChenu

DenisChenu

2012-06-21 15:16

developer   ~19445

Carsten,
Can you give me the MSSQL error ?
It work on pgSQL and mySQL (it's SQL langage, not mysql specific)

And if i look to MSSQL documentation, SUM(CASE() have to work.

Denis

(and after assign it to me)

c_schmitz

c_schmitz

2012-06-21 15:22

administrator   ~19446

Last edited: 2012-06-21 15:23

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]The data types text and varchar are in the equal to-Operator incompatible.. The SQL statement executed was: SELECT COUNT(*) as tkcount,
SUM(CASE WHEN (token IS NULL OR token='') THEN 1 ELSE 0 END) as tkinvalid,
SUM(CASE WHEN (sent!='N' and sent<>'') THEN 1 ELSE 0 END) as tksent,
SUM(CASE WHEN (emailstatus = 'OptOut') THEN 1 ELSE 0 END) as tkoptout,
SUM(CASE WHEN (completed!='N' and completed<>'') THEN 1 ELSE 0 END) as tkcompleted

FROM [lime_tokens_167949]

DenisChenu

DenisChenu

2012-06-21 15:59

developer   ~19447

OK,

Can you test with:

public function summary()
{
    $sid = self::$sid;
    if(Yii::app()->db->schema->getTable(&quot;{{tokens_$sid}}&quot;)){
        $data=Yii::app()->db->createCommand()
            ->select(&quot;COUNT(*) as tkcount, 
                        SUM(CASE WHEN (token IS NULL OR token='') THEN 1 ELSE 0 END) as tkinvalid, 
                        SUM(CASE WHEN (sent!='N' and sent&lt;>'') THEN 1 ELSE 0 END) as tksent, 
                        SUM(CASE WHEN (emailstatus LIKE 'OptOut%') THEN 1 ELSE 0 END) as tkoptout,
                        SUM(CASE WHEN (completed!='N' and completed&lt;>'') THEN 1 ELSE 0 END) as tkcompleted
                        &quot;)
            ->from(&quot;{{tokens_$sid}}&quot;)
            ->queryRow();
    }
    else
    {
        $data=false;
    }

    return $data;
}

Replace
SUM(CASE WHEN (emailstatus = 'OptOut') THEN 1 ELSE 0 END) as tkoptout,

by

SUM(CASE WHEN (emailstatus like 'OptOut%') THEN 1 ELSE 0 END) as tkoptout,

Tested with mysql and pgsql
And the user can add some information on the OptOut reason for example (i they want)

Thanks

c_schmitz

c_schmitz

2012-06-23 17:11

administrator   ~19519

Yes, works fine,

even

SUM(CASE WHEN (emailstatus like 'OptOut') THEN 1 ELSE 0 END) as tkoptout,

works. No % needed.

DenisChenu

DenisChenu

2012-06-23 18:42

developer   ~19528

Fix committed to Yii branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=8856

c_schmitz

c_schmitz

2012-07-19 23:34

administrator   ~19838

2.00RC6 released.

Related Changesets

LimeSurvey: Yii 3336fac3

2012-05-30 07:41:51

DenisChenu

Details Diff
Fixed issue 06138 : Undefined index: count(tid) in Tokens_dynamic.php with postgresql
Dev: remove queryX from Tokens_dynamic::model($sid)->summary();
Dev: use SUM(CASE WHEN : tested with pgsql/mysql.
Affected Issues
06138
mod - application/controllers/admin/tokens.php Diff File
mod - application/models/Tokens_dynamic.php Diff File
mod - application/views/admin/token/tokensummary.php Diff File

LimeSurvey: Yii 249c832c

2012-06-23 09:40:26

DenisChenu

Details Diff
Fixed issue 06138 : crash MSSQL in token information
Dev : keep % to have information with token admin edit
Affected Issues
06138
mod - application/models/Tokens_dynamic.php Diff File

Issue History

Date Modified Username Field Change
2012-05-27 14:47 adoubleu New Issue
2012-05-27 14:49 adoubleu File Added: phpNotice.pdf
2012-05-28 18:31 c_schmitz Assigned To => DenisChenu
2012-05-28 18:31 c_schmitz Status new => assigned
2012-05-30 16:43 DenisChenu Changeset attached => LimeSurvey Yii 3336fac3
2012-05-30 16:43 DenisChenu Note Added: 19003
2012-05-30 16:43 DenisChenu Resolution open => fixed
2012-05-30 16:45 DenisChenu Status assigned => resolved
2012-05-30 16:45 DenisChenu Fixed in Version => 2.00RC3
2012-06-20 14:05 c_schmitz Note Added: 19379
2012-06-20 14:05 c_schmitz Status resolved => closed
2012-06-21 13:46 c_schmitz Note Added: 19437
2012-06-21 13:46 c_schmitz Status closed => feedback
2012-06-21 13:46 c_schmitz Resolution fixed => reopened
2012-06-21 14:48 DenisChenu Note Added: 19443
2012-06-21 14:48 DenisChenu Note Edited: 19443
2012-06-21 15:16 DenisChenu Assigned To DenisChenu => c_schmitz
2012-06-21 15:16 DenisChenu Status feedback => assigned
2012-06-21 15:16 DenisChenu Note Added: 19445
2012-06-21 15:22 c_schmitz Note Added: 19446
2012-06-21 15:23 c_schmitz Note Edited: 19446
2012-06-21 15:59 DenisChenu Note Added: 19447
2012-06-23 17:11 c_schmitz Note Added: 19519
2012-06-23 17:11 c_schmitz Assigned To c_schmitz => DenisChenu
2012-06-23 18:42 DenisChenu Changeset attached => LimeSurvey Yii 249c832c
2012-06-23 18:42 DenisChenu Note Added: 19528
2012-06-23 18:50 DenisChenu Status assigned => resolved
2012-06-23 18:50 DenisChenu Fixed in Version 2.00RC3 => 2.00RC5
2012-06-23 18:50 DenisChenu Resolution reopened => fixed
2012-07-19 23:34 c_schmitz Note Added: 19838
2012-07-19 23:34 c_schmitz Status resolved => closed
2016-12-08 10:39 c_schmitz Category Tokens => Survey participants (Tokens)