Skip to content

Commit

Permalink
fix(checkboxfield): avoid unicode escaping
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed May 23, 2020
1 parent 2b43125 commit 3276b9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion inc/fields/checkboxesfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function serializeValue() {
return '';
}

return Toolbox::addslashes_deep(json_encode($this->value, JSON_OBJECT_AS_ARRAY));
return Toolbox::addslashes_deep(json_encode($this->value, JSON_OBJECT_AS_ARRAY+JSON_UNESCAPED_UNICODE));
}

public function deserializeValue($value) {
Expand Down
18 changes: 9 additions & 9 deletions install/upgrade_to_2.11.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,24 @@ public function upgrade(Migration $migration) {
$table = 'glpi_plugin_formcreator_targettickets';
$migration->addPostQuery("ALTER TABLE `$table` MODIFY `uuid` varchar(255) DEFAULT NULL AFTER `show_rule`");

$this->migrateCheckboxes();
$this->migrateRadios();
$this->migrateCheckboxesAndMultiselect();
$this->migrateRadiosAndSelect();
}

/**
* Migrate checkboxes data to JSON
* Migrate checkboxes and multiselect data to JSON
*
* @return void
*/
public function migrateCheckboxes() {
public function migrateCheckboxesAndMultiselect() {
global $DB;

// Migrate default value
$questionTable = 'glpi_plugin_formcreator_questions';
$request = [
'SELECT' => ['id', 'default_values', 'values'],
'FROM' => $questionTable,
'WHERE' => ['fieldtype' => ['checkboxes']],
'WHERE' => ['fieldtype' => ['checkboxes', 'multiselect']],
];
foreach($DB->request($request) as $row) {
$newValues = $row['values'];
Expand Down Expand Up @@ -130,7 +130,7 @@ public function migrateCheckboxes() {
]
]
],
'WHERE' => ['fieldtype' => 'checkboxes'],
'WHERE' => ['fieldtype' => 'checkboxes', 'multiselect'],
];
foreach ($DB->request($request) as $row) {
$newAnswer = $row['answer'];
Expand All @@ -144,19 +144,19 @@ public function migrateCheckboxes() {
}

/**
* Migrate radios data to JSON
* Migrate radios and select data to JSON
*
* @return void
*/
public function migrateRadios() {
public function migrateRadiosAndSelect() {
global $DB;

// Migrate default value
$questionTable = 'glpi_plugin_formcreator_questions';
$request = [
'SELECT' => ['id', 'default_values', 'values'],
'FROM' => $questionTable,
'WHERE' => ['fieldtype' => ['radios']],
'WHERE' => ['fieldtype' => ['radios', 'select']],
];
foreach($DB->request($request) as $row) {
$newValues = $row['values'];
Expand Down

0 comments on commit 3276b9a

Please sign in to comment.