From 6e609576c3fea193d29cadd647bce62929621176 Mon Sep 17 00:00:00 2001 From: encelado Date: Fri, 30 Oct 2015 10:57:36 +0100 Subject: [PATCH] Fixed issue: 'token' column collation is not (always) set in survey tables --- application/helpers/admin/activate_helper.php | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/application/helpers/admin/activate_helper.php b/application/helpers/admin/activate_helper.php index 24506dcc112..9c46e76a5ef 100644 --- a/application/helpers/admin/activate_helper.php +++ b/application/helpers/admin/activate_helper.php @@ -259,6 +259,15 @@ function activateSurvey($iSurveyID, $simulate = false) $createsurveytimings=''; $fieldstiming = array(); $createsurveydirectory=false; + // Specify case sensitive collations for the token + $sCollation=''; + if (Yii::app()->db->driverName=='mysqli' | Yii::app()->db->driverName=='mysqli'){ + $sCollation=" COLLATE 'utf8_bin'"; + } + if (Yii::app()->db->driverName=='sqlsrv' | Yii::app()->db->driverName=='dblib' | Yii::app()->db->driverName=='mssql'){ + $sCollation=" COLLATE SQL_Latin1_General_CP1_CS_AS"; + } + //Check for any additional fields for this survey and create necessary fields (token and datestamp) $prow = Survey::model()->findByAttributes(array('sid' => $iSurveyID)); @@ -343,15 +352,7 @@ function activateSurvey($iSurveyID, $simulate = false) $createsurvey[$arow['fieldname']] = "string"; break; case "token": - // Specify case sensitive collations for the token - $sCollation=''; - if (Yii::app()->db->driverName=='mysqli' | Yii::app()->db->driverName=='mysqli'){ - $sCollation=" COLLATE 'utf8_bin'"; - } - if (Yii::app()->db->driverName=='sqlsrv' | Yii::app()->db->driverName=='dblib' | Yii::app()->db->driverName=='mssql'){ - $sCollation=" COLLATE SQL_Latin1_General_CP1_CS_AS"; - } - $createsurvey[$arow['fieldname']] = 'string(35)'.$sCollation; + $createsurvey[$arow['fieldname']] = 'string(35)'.$sCollation; break; case '*': // Equation $createsurvey[$arow['fieldname']] = "text"; @@ -359,9 +360,9 @@ function activateSurvey($iSurveyID, $simulate = false) default: $createsurvey[$arow['fieldname']] = "string(5)"; } - if ($prow->anonymized == 'N' && !array_key_exists('token',$createsurvey)) { - $createsurvey['token'] = "string(36)"; - } + if ($prow->anonymized == 'N' && !array_key_exists('token',$createsurvey)){ + $createsurvey['token'] = 'string(35)'.$sCollation; + } if ($simulate){ $tempTrim = trim($createsurvey); $brackets = strpos($tempTrim,"(");