Skip to content

Commit

Permalink
Fix migrate processor + grid getlist to check decrypted values for co…
Browse files Browse the repository at this point in the history
…rrect json.
  • Loading branch information
joeke committed Apr 26, 2017
1 parent 98bf8d5 commit 7abe4e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions core/components/formit/processors/mgr/form/getlist.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ public function prepareQueryBeforeCount(xPDOQuery $c)
public function prepareRow(xPDOObject $object)
{
$ff = $object->toArray();
if ($ff['encrypted']){
$ff['values'] = $object->decrypt($ff['values']);
if ($ff['encrypted']) {
$values = $object->decrypt($ff['values']);
if (!is_array(json_decode($values, true))) {
$values = $object->decrypt($ff['values'], 1);
}
$ff['values'] = $values;
}

return $ff;
Expand Down
7 changes: 6 additions & 1 deletion core/components/formit/processors/mgr/form/migrate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public function process()
}
$oldValues = $form->get('values');
$oldValues = $form->decrypt($oldValues, 1);
$newValues = $form->encrypt($oldValues);
/* Fix for when forms are encrypted with openssl, but encryption_type field is not set to 2 */
if (!is_array(json_decode($oldValues, true))) {
$newValues = $form->get('values');
} else {
$newValues = $form->encrypt($oldValues);
}
if ($newValues) {
$this->modx->exec("UPDATE {$this->modx->getTableName('FormItForm')}
SET {$this->modx->escape('encryption_type')} = {$this->modx->quote(2)},
Expand Down

0 comments on commit 7abe4e7

Please sign in to comment.