Skip to content

Commit

Permalink
Fixed issue #16179: Update 3.20.2 -> 4.2.0 running into database error
Browse files Browse the repository at this point in the history
  • Loading branch information
Trischi80 committed Apr 24, 2020
1 parent 0e33f55 commit c7cfa9e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 12 deletions.
62 changes: 51 additions & 11 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -3570,18 +3570,58 @@ function createSurveysGroupSettingsTable(CDbConnection $oDB)

$oDB->createCommand()->insert("{{surveys_groupsettings}}", $attributes);

//this will fail because of using model in updatedb_helper ...
// insert settings for default survey group
$settings2 = new SurveysGroupsettings;
$settings2->setToInherit();
$settings2->gsid = 1;

// Quick hack to remote ipanonymize.
// TODO: Don't use models in updatedb_helper. ok
$attributes = $settings2->attributes;
unset($attributes['ipanonymize']);

$oDB->createCommand()->insert("{{surveys_groupsettings}}", $attributes);

//$settings2 = new SurveysGroupsettings;
//$settings2->gsid = 1;
//$settings2->setToInherit(); //we can not use this function because of ipanonymize (again: never use models in update_helper)

$attributes2 = array(
"gsid" => 1,
"owner_id" => -1,
"admin" => "inherit",
"adminemail" => "inherit",
"anonymized" => "I",
"format" => "I",
"savetimings" => "I",
"template" => "inherit",
"datestamp" => "I",
"usecookie" => "I",
"allowregister" => "I",
"allowsave" => "I",
"autonumber_start" => 0,
"autoredirect" => "I",
"allowprev" => "I",
"printanswers" => "I",
"ipaddr" => "I",
"refurl" => "I",
"showsurveypolicynotice" => 0,
"publicstatistics" => "I",
"publicgraphs" => "I",
"listpublic" => "I",
"htmlemail" => "I",
"sendconfirmation" => "I",
"tokenanswerspersistence" => "I",
"assessments" => "I",
"usecaptcha" => "E",
"bounce_email" => "inherit",
"attributedescriptions" => NULL,
"emailresponseto" => "inherit",
"emailnotificationto" => "inherit",
"tokenlength" => -1,
"showxquestions" => "I",
"showgroupinfo" => "I",
"shownoanswer" => "I",
"showqnumcode" => "I",
"showwelcome" => "I",
"showprogress" => "I",
"questionindex" => -1,
"navigationdelay" => -1,
"nokeyboard" => "I",
"alloweditaftercompletion" => "I",
);

$oDB->createCommand()->insert("{{surveys_groupsettings}}", $attributes2);
}
/**
* @param CDbConnection $oDB
Expand Down
6 changes: 5 additions & 1 deletion application/models/SurveysGroupsettings.php
Expand Up @@ -437,7 +437,11 @@ public function setToInherit()
$this->$attribute = -1;
}
foreach ($this->optionAttributesChar as $attribute){
$this->$attribute = 'I';
//fix for 16179
$dbversion = GetGlobalSetting('DBVersion');
if( !($attribute==='ipanonymize' && ( $dbversion < 412 ))){
$this->$attribute = 'I';
}
}
foreach ($this->optionAttributesText as $attribute){
$this->$attribute = 'inherit';
Expand Down

0 comments on commit c7cfa9e

Please sign in to comment.