Skip to content

Commit

Permalink
[MAJOR] Correct issue that wipe catalog links when update a catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
jjrom committed Nov 25, 2024
1 parent a7b2fef commit af589ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/resto/core/RestoConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RestoConstants
// [IMPORTANT] Starting resto 7.x, default routes are defined in RestoRouter class

// resto version
const VERSION = '9.0.6';
const VERSION = '9.0.7';

/* ============================================================
* NEVER EVER TOUCH THESE VALUES
Expand Down
19 changes: 5 additions & 14 deletions app/resto/core/api/STACAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public function updateCatalog($params, $body)
'noCount' => true,
'noProperties' => true
), $this->context->core['baseUrl'], true);

if ( count($catalogs) === 0 ){
RestoLogUtil::httpError(404);
}
Expand Down Expand Up @@ -546,21 +546,12 @@ public function updateCatalog($params, $body)
return RestoLogUtil::httpError(400, 'The catalog update would remove ' . $removed . ' existing child(s). Set **_force** query parameter to true to force update anyway');
}

// [IMPORTANT] Replace collection input links with updated
$catalogs[0]['links'] = $body['links'];
}
else {
unset($catalogs[0]['links']);
}

// Add body additional properties
foreach (array_keys($body) as $key ) {
if ( in_array($key, CatalogsFunctions::CATALOG_PROPERTIES) ){
$catalogs[0][$key] = $body[$key];
}
}

return $this->catalogsFunctions->updateCatalog($catalogs[0], $this->user->profile['id'], $this->context) ? RestoLogUtil::success('Catalog updated') : RestoLogUtil::error('Cannot update catalog');
// [TODO] not sure it's needed
$body['id'] = $catalogs[0]['id'];

return $this->catalogsFunctions->updateCatalog($body, $this->user->profile['id'], $this->context) ? RestoLogUtil::success('Catalog updated') : RestoLogUtil::error('Cannot update catalog');
}

/**
Expand Down

0 comments on commit af589ca

Please sign in to comment.