diff --git a/lib/Db/Publication.php b/lib/Db/Publication.php index 18949079..45c49dfb 100644 --- a/lib/Db/Publication.php +++ b/lib/Db/Publication.php @@ -78,10 +78,15 @@ public function hydrate(array $object): self $this->setModified(new DateTime()); - if(isset($object['published']) === false) { + if (isset($object['published']) === false) { $object['published'] = null; } + // Todo: MetaData is depricated, we should use Schema instead. But this needs front-end changes as well. + if (empty($object['schema']) === true) { + $object['schema'] = $object['metaData'] ?? $this->getMetaData(); + } + foreach($object as $key => $value) { if (in_array($key, $jsonFields) === true && $value === []) { $value = null; @@ -96,9 +101,6 @@ public function hydrate(array $object): self } } - // Todo: MetaData is depricated, we should use Schema instead. But this needs front-end changes as well. - $this->setSchema($this->getMetaData()); - $this->setAttachmentCount('0'); if($this->attachments !== null) { $this->setAttachmentCount(count($this->getAttachments())); @@ -127,7 +129,7 @@ public function jsonSerialize(): array 'data' => $this->data, 'attachments' => $this->attachments, 'attachmentCount' => $this->attachmentCount, - 'schema' => $this->schema, + 'schema' => json_decode($this->schema, true), 'status' => $this->status, 'license' => $this->license, 'themes' => $this->themes,