Skip to content

Commit

Permalink
New feature: E-Mail bodies allow now for more than 64kb size when usi…
Browse files Browse the repository at this point in the history
…ng MySQL

Fixed issue: Error when too many translations are added to a survey
  • Loading branch information
c-schmitz committed Oct 7, 2020
1 parent 4315c67 commit 4b7991e
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 89 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


$config['versionnumber'] = '3.23.7';
$config['dbversionnumber'] = 363;
$config['dbversionnumber'] = 364;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['templateapiversion'] = 3;
Expand Down
27 changes: 6 additions & 21 deletions application/controllers/admin/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -734,14 +734,8 @@ private function actionUpdateQuestion($iSurveyID)
foreach ($udata as $k => $v) {
$oQuestion->$k = $v;
}
try {
$uqresult = $oQuestion->save();
} catch(CDbException $e) {
$uqresult=false;
if ($e->errorInfo[0]==22001) { // This should only happen on MySQL
Yii::app()->setFlashMessage(gT("Error: Question text length exceeds 64kb."), 'error');
}
}

$uqresult = $oQuestion->save(); //($uqquery); // or safeDie ("Error Update Question: ".$uqquery."<br />"); // Checked)
if (!$uqresult) {
$bOnError = true;
$aErrors = $oQuestion->getErrors();
Expand Down Expand Up @@ -1291,15 +1285,7 @@ private function actionInsertCopyQuestion($iSurveyID)
$oQuestion->relevance = Yii::app()->request->getPost('relevance');
$oQuestion->question_order = (int) $iQuestionOrder;
$oQuestion->language = $sBaseLanguage;

try {
$oQuestion->save();
} catch(CDbException $e) {
if ($e->errorInfo[0]==22001) { // This should only happen on MySQL
Yii::app()->setFlashMessage(gT("Error: Question text length exceeds 64kb."), 'error');
}
}

$oQuestion->save();
if ($oQuestion) {
$this->iQuestionID = $oQuestion->qid;
}
Expand Down Expand Up @@ -1518,12 +1504,11 @@ private function actionInsertCopyQuestion($iSurveyID)
}
//This is SUPER important! Recalculating the Expression Manager state!
LimeExpressionManager::SetDirtyFlag(); // so refreshes syntax highlighting

if (Yii::app()->request->getPost('saveandnew', '') != '' || !$this->iQuestionID) {
$redirectLink = $this->getController()->createUrl('admin/questions/sa/view/', array('surveyid' => $iSurveyID, 'gid' => $this->iQuestionGroupID, 'qid' => $this->iQuestionID));
if (Yii::app()->request->getPost('saveandnew', '') != '') {
$redirectLink = $this->getController()->createUrl('admin/questions/sa/newquestion/', array('surveyid' => $iSurveyID, 'gid' => $this->iQuestionGroupID));
} else {
$redirectLink = $this->getController()->createUrl('admin/questions/sa/view/', array('surveyid' => $iSurveyID, 'gid' => $this->iQuestionGroupID, 'qid' => $this->iQuestionID));
}

$this->getController()->redirect($redirectLink);
}

Expand Down
2 changes: 2 additions & 0 deletions application/core/db/MssqlSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public function __construct($conn)
* Recommended practice.
*/
$this->columnTypes['text'] = 'nvarchar(max)';
$this->columnTypes['mediumtext'] = 'nvarchar(max)';
$this->columnTypes['longtext'] = 'nvarchar(max)';
/**
* DbLib bugs if no explicit NOT NULL is specified.
*/
Expand Down
2 changes: 2 additions & 0 deletions application/core/db/PgsqlSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public function __construct($conn)
$this->columnTypes['autoincrement'] = 'serial';
$this->columnTypes['longbinary'] = 'bytea';
$this->columnTypes['decimal'] = 'numeric (10,0)'; // Same default than MySql (not used)
$this->columnTypes['mediumtext'] = 'text';
$this->columnTypes['longtext'] = 'text';
}

/**
Expand Down
52 changes: 49 additions & 3 deletions application/helpers/update/updatedb_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
- Never use models in the upgrade process - never ever!
- Use the provided addColumn, alterColumn, dropPrimaryKey etc. functions where applicable - they ensure cross-DB compatibility
- Never use foreign keys
- Do not use fancy database field types (like mediumtext, timestamp, etc) - only use the ones provided by Yii which are:
- Use only the field types listed here:
pk: auto-incremental primary key type (“int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY”).
string: string type (“varchar(255)”).
text: a long string type (“text”).
text: a long string type (“text”) - MySQL: max size 64kb - Postgres: unlimited - MSSQL: max size 2.1GB
mediumtext: a long string type (“text”) - MySQL: max size 16MB - Postgres: unlimited - MSSQL: max size 2.1GB
longtext: a long string type (“text”) - MySQL: max size 2.1 GB - Postgres: unlimited - MSSQL: max size 2.1GB
integer: integer type (“int(11)”).
boolean: boolean type (“tinyint(1)”).
float: float number type (“float”).
decimal: decimal number type (“decimal”).
datetime: datetime type (“datetime”).
timestamp: timestamp type (“timestamp”).
time: time type (“time”).
date: date type (“date”).
binary: binary data type (“blob”).
Expand Down Expand Up @@ -2481,6 +2482,51 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false)
$oTransaction->commit();
}

/*
* Extend text datafield lengths for MySQL
* Extend datafield length for additional languages in survey table
*/
if ($iOldDBVersion < 364) {
$oTransaction = $oDB->beginTransaction();
if (Yii::app()->db->driverName=='mysql' || Yii::app()->db->driverName=='mysqi') {
alterColumn('{{answers}}','answer',"mediumtext",false);
alterColumn('{{assessments}}','message',"mediumtext",false);
alterColumn('{{groups}}','description',"mediumtext");
alterColumn('{{notifications}}','message',"mediumtext",false);
alterColumn('{{participant_attribute_values}}','value',"mediumtext",false);
alterColumn('{{plugin_settings}}','value',"mediumtext");
alterColumn('{{questions}}','question',"mediumtext",false);
alterColumn('{{questions}}','help',"mediumtext");
alterColumn('{{question_attributes}}','value',"mediumtext");
alterColumn('{{quota_languagesettings}}','quotals_message',"mediumtext",false);
alterColumn('{{settings_global}}','stg_value',"mediumtext",false);
alterColumn('{{settings_user}}','stg_value',"mediumtext");
alterColumn('{{surveymenu_entries}}','data',"mediumtext");
alterColumn('{{surveys}}','attributedescriptions',"mediumtext");
alterColumn('{{surveys_languagesettings}}','surveyls_description',"mediumtext");
alterColumn('{{surveys_languagesettings}}','surveyls_welcometext',"mediumtext");
alterColumn('{{surveys_languagesettings}}','surveyls_endtext',"mediumtext");
alterColumn('{{surveys_languagesettings}}','surveyls_policy_notice',"mediumtext");
alterColumn('{{surveys_languagesettings}}','surveyls_email_invite',"mediumtext");
alterColumn('{{surveys_languagesettings}}','surveyls_email_remind',"mediumtext");
alterColumn('{{surveys_languagesettings}}','surveyls_email_register',"mediumtext");
alterColumn('{{surveys_languagesettings}}','surveyls_email_confirm',"mediumtext");
alterColumn('{{surveys_languagesettings}}','email_admin_notification',"mediumtext");
alterColumn('{{surveys_languagesettings}}','email_admin_responses',"mediumtext");
alterColumn('{{templates}}','license',"mediumtext");
alterColumn('{{templates}}','description',"mediumtext");
alterColumn('{{template_configuration}}','cssframework_css',"mediumtext");
alterColumn('{{template_configuration}}','cssframework_js',"mediumtext");
alterColumn('{{tutorials}}','settings',"mediumtext");
alterColumn('{{tutorial_entries}}','content',"mediumtext");
alterColumn('{{tutorial_entries}}','settings',"mediumtext");
}
alterColumn('{{surveys}}','additional_languages',"text");
$oDB->createCommand()->update('{{settings_global}}', ['stg_value'=>364], "stg_name='DBVersion'");
$oTransaction->commit();
}


} catch (Exception $e) {
Yii::app()->setConfig('Updating', false);
$oTransaction->rollback();
Expand Down

0 comments on commit 4b7991e

Please sign in to comment.