Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ public function post(string $schema_id, string $identifier, Request $request) {
$data = json_decode($request->getContent());
$entity->set('moderation_state', $data->state);
$entity->setRevisionLogMessage($data->message);
if ($entity->isNewRevision()) {
// Set revision creation time to the current time because
// revisions will reuse the previous revision's timestamp if not set.
$time = new \DateTimeImmutable();
$entity->setRevisionCreationTime($time->getTimestamp());
}
$entity->save();
}
catch (\Exception $e) {
Expand Down
6 changes: 6 additions & 0 deletions modules/dkan_metastore/src/NodeWrapper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ public function getModerationState() {
* service's POST and PUT functions rather than saving the node directly.
*/
public function save() {
if ($this->node->getEntityType()->isRevisionable() && $this->node->isNewRevision()) {
// Set revision creation time to the current time because
// revisions will reuse the previous revision's timestamp if not set.
$time = new \DateTimeImmutable();
$this->node->setRevisionCreationTime($time->getTimestamp());
}
$this->node->save();
}

Expand Down
6 changes: 6 additions & 0 deletions modules/dkan_metastore/src/Reference/Referencer.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ protected function checkExistingReference(string $property_id, $data) {
// If an existing referenced node is found but unpublished, publish it.
if ($node->get('moderation_state')->value !== 'published') {
$node->set('moderation_state', 'published');
if ($node->getEntityType()->isRevisionable() && $node->isNewRevision()) {
// Set revision creation time to the current time because
// revisions will reuse the previous revision's timestamp if not set.
$time = new \DateTimeImmutable();
$node->setRevisionCreationTime($time->getTimestamp());
}
$node->save();
}
return $node->uuid();
Expand Down
6 changes: 6 additions & 0 deletions modules/dkan_metastore/src/Storage/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ protected function setWorkflowState(string $uuid, string $state): bool {
}
elseif ($state !== $entity->get('moderation_state')->getString()) {
$entity->set('moderation_state', $state);
if ($entity->getEntityType()->isRevisionable() && $entity->isNewRevision()) {
// Set revision creation time to the current time because
// revisions will reuse the previous revision's timestamp if not set.
$time = new \DateTimeImmutable();
$entity->setRevisionCreationTime($time->getTimestamp());
}
$entity->save();
return TRUE;
}
Expand Down