fix: [internal] Update object relationships when updating JSONs

pull/7530/head
Jakub Onderka 2021-06-30 10:23:14 +02:00
parent 6e61258e0d
commit 5b27fabc05
2 changed files with 4 additions and 5 deletions

View File

@ -46,13 +46,13 @@ class ObjectRelationship extends AppModel
$relationsFile = APP . 'files/misp-objects/relationships/definition.json';
if (file_exists($relationsFile)) {
$file = new File($relationsFile);
$relations = json_decode($file->read(), true);
$relations = $this->jsonDecode($file->read());
if (!isset($relations['version'])) {
$relations['version'] = 1;
}
$this->deleteAll(array('version <' => $relations['version']));
foreach ($relations['values'] as $k => $relation) {
$relation['format'] = json_encode($relation['format'], true);
foreach ($relations['values'] as $relation) {
$relation['format'] = json_encode($relation['format']);
$relation['version'] = $relations['version'];
$this->create();
$this->save($relation);

View File

@ -4250,9 +4250,8 @@ class Server extends AppModel
public function updateJSON()
{
$toUpdate = array('Galaxy', 'Noticelist', 'Warninglist', 'Taxonomy', 'ObjectTemplate');
$results = array();
foreach ($toUpdate as $target) {
foreach (['Galaxy', 'Noticelist', 'Warninglist', 'Taxonomy', 'ObjectTemplate', 'ObjectRelationship'] as $target) {
$this->$target = ClassRegistry::init($target);
$result = $this->$target->update();
$results[$target] = $result === false ? false : true;