@@ -452,8 +452,8 @@ private function storeCatalog($catalog, $userid, $context, $collectionId, $featu
452
452
453
453
$ cleanLinks = $ this ->getCleanLinks ($ catalog , $ userid , $ context );
454
454
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 (
457
457
$ catalog ['id ' ],
458
458
$ catalog ['title ' ] ?? $ catalog ['id ' ],
459
459
$ catalog ['description ' ] ?? null ,
@@ -464,10 +464,16 @@ private function storeCatalog($catalog, $userid, $context, $collectionId, $featu
464
464
'collections ' => array ()
465
465
), JSON_UNESCAPED_SLASHES )),
466
466
$ catalog ['owner ' ] ?? $ userid ,
467
- json_encode ($ cleanLinks ['links ' ], JSON_UNESCAPED_SLASHES ),
468
467
RestoConstants::GROUP_DEFAULT_ID ,
469
468
$ 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 ' ]);
471
477
472
478
/*
473
479
* Catalog id are like this
0 commit comments