-
Notifications
You must be signed in to change notification settings - Fork 991
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue #CR-1347: duplicate entries in template configuration and…
… incorrect theme being saved in general settings or loaded when a theme does not exist (#3491) * prevent duplicate entries from being created and delete duplicates * fix caching for surveys during requests * add check to getInstance to prevent and invalid template to be loaded * added the inherited template name to display when selecting the theme in general settings of survey instead of a survey groups default --------- Co-authored-by: Kevin Foster <kevin.foster.uk@gmail.com>
- Loading branch information
1 parent
8fb2dce
commit 5518eaf
Showing
11 changed files
with
104 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace LimeSurvey\Helpers\Update; | ||
|
||
use CDbException; | ||
use CException; | ||
|
||
class Update_617 extends DatabaseUpdateBase | ||
{ | ||
/** | ||
* @inheritDoc | ||
* @throws CException | ||
*/ | ||
public function up(): void | ||
{ | ||
$this->deleteDuplicateTemplateConfigurationEntries(); | ||
} | ||
|
||
/** | ||
* @throws CDbException | ||
* @throws CException | ||
*/ | ||
private function deleteDuplicateTemplateConfigurationEntries(): void | ||
{ | ||
$aKeepIds = $this->db->createCommand() | ||
->select("MAX(id) AS maxRecordId") | ||
->from("{{template_configuration}}") | ||
->group(['template_name', 'sid', 'gsid', 'uid']) | ||
->queryAll(); | ||
$aKeepIds = array_column($aKeepIds, 'maxRecordId'); | ||
$criteria = $this->db->getCommandBuilder()->createCriteria(); | ||
$criteria->select = 'id, template_name, sid, gsid, uid'; | ||
$criteria->addNotInCondition('id', $aKeepIds); | ||
$this->db->getCommandBuilder()->createDeleteCommand('{{template_configuration}}', $criteria)->execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.