mirror of https://github.com/MISP/MISP
fix: [internal] Update object relationships when updating JSONs
parent
6e61258e0d
commit
5b27fabc05
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue