Skip to content

Commit b879017

Browse files
authored
Merge pull request #460 from jjrom/develop
Typo in links
2 parents 0aee9c5 + 1bea4c7 commit b879017

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

app/resto/core/RestoConstants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RestoConstants
2020
// [IMPORTANT] Starting resto 7.x, default routes are defined in RestoRouter class
2121

2222
// resto version
23-
const VERSION = '9.0.0-RC22';
23+
const VERSION = '9.0.0-RC23';
2424

2525
/* ============================================================
2626
* NEVER EVER TOUCH THESE VALUES

app/resto/core/dbfunctions/CatalogsFunctions.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ private function storeCatalog($catalog, $userid, $context, $collectionId, $featu
452452

453453
$cleanLinks = $this->getCleanLinks($catalog, $userid, $context);
454454

455-
$insert = 'INSERT INTO ' . $this->dbDriver->targetSchema . '.catalog (id, title, description, level, counters, owner, links, visibility, rtype, created) SELECT $1,$2,$3,$4,$5,$6,$7,$8,$9,now() ON CONFLICT (id) DO NOTHING';
456-
$this->dbDriver->pQuery($insert, array(
455+
$insert = '(id, title, description, level, counters, owner, visibility, rtype, created) SELECT $1,$2,$3,$4,$5,$6,$7,$8,now()';
456+
$values = array(
457457
$catalog['id'],
458458
$catalog['title'] ?? $catalog['id'],
459459
$catalog['description'] ?? null,
@@ -464,10 +464,16 @@ private function storeCatalog($catalog, $userid, $context, $collectionId, $featu
464464
'collections' => array()
465465
), JSON_UNESCAPED_SLASHES)),
466466
$catalog['owner'] ?? $userid,
467-
json_encode($cleanLinks['links'], JSON_UNESCAPED_SLASHES),
468467
RestoConstants::GROUP_DEFAULT_ID,
469468
$catalog['rtype'] ?? null
470-
), 500, 'Cannot insert catalog ' . $catalog['id']);
469+
);
470+
if ( isset($cleanLinks['links']) ) {
471+
$values[] = json_encode($cleanLinks['links'] ?? array(), JSON_UNESCAPED_SLASHES);
472+
$insert = '(id, title, description, level, counters, owner, visibility, rtype, links, created) SELECT $1,$2,$3,$4,$5,$6,$7,$8,$9,now()';
473+
}
474+
475+
$insert = 'INSERT INTO ' . $this->dbDriver->targetSchema . '.catalog (id, title, description, level, counters, owner, links, visibility, rtype, created) SELECT $1,$2,$3,$4,$5,$6,$7,$8,$9,now() ON CONFLICT (id) DO NOTHING';
476+
$this->dbDriver->pQuery($insert, $values, 500, 'Cannot insert catalog ' . $catalog['id']);
471477

472478
/*
473479
* Catalog id are like this

docs/COLLECTIONS_AND_CATALOGS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ is to create an empty catalog then add its childs through the POST API
100100
curl -X PUT -d@examples/catalogs/dummyCatalog_update.json "http://admin:admin@localhost:5252/catalogs/dummyCatalog"
101101
102102
# Use _force flag to force links update
103+
curl -X PUT -d@examples/catalogs/dummyCatalog_update.json "http://admin:admin@localhost:5252/catalogs/dummyCatalog?_force=1"
103104

104-
105+
### Update a catalog changing everything except links
106+
107+
# If the links property is not set, then existing links will not be affected
105108

106109
### Delete a catalog
107110

0 commit comments

Comments
 (0)