Import: always store dictionaries ordered
This commit is contained in:
parent
b7cd26b597
commit
5f333b0ea7
|
@ -61,7 +61,7 @@ class Import
|
|||
$pval = json_encode($pval);
|
||||
$format = 'json';
|
||||
} elseif ($pval instanceof stdClass) {
|
||||
$pval = json_encode($pval);
|
||||
$pval = json_encode($this->sortObject($pval));
|
||||
$format = 'json';
|
||||
} else {
|
||||
$format = 'string';
|
||||
|
@ -159,6 +159,32 @@ class Import
|
|||
return $id;
|
||||
}
|
||||
|
||||
protected function sortObject($object)
|
||||
{
|
||||
$array = (array) $object;
|
||||
foreach ($array as $key => $val) {
|
||||
$this->sortElement($val);
|
||||
}
|
||||
ksort($array);
|
||||
return (object) $array;
|
||||
}
|
||||
|
||||
protected function sortArrayObject(& $array)
|
||||
{
|
||||
foreach ($array as $key => $val) {
|
||||
$this->sortElement($val);
|
||||
}
|
||||
}
|
||||
|
||||
protected function sortElement(& $el)
|
||||
{
|
||||
if (is_array($el)) {
|
||||
$this->sortArrayObject($el);
|
||||
} elseif ($el instanceof stdClass) {
|
||||
$el = $this->sortObject($el);
|
||||
}
|
||||
}
|
||||
|
||||
protected function rowSetExists($checksum)
|
||||
{
|
||||
return count($this->newChecksums('imported_rowset', array($checksum))) === 0;
|
||||
|
|
Loading…
Reference in New Issue