From 577d7ced4fab9ff2fe31804c59d71bf3a653b06e Mon Sep 17 00:00:00 2001 From: Thiago Matos Date: Wed, 24 Apr 2024 18:03:57 -0400 Subject: [PATCH] Fixes discussions import/export --- .../ExtendedArticleNativeXmlFilter.inc.php | 16 +++++++++++----- .../NativeXmlExtendedArticleFilter.inc.php | 4 ++-- fullJournal.xsd | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/filter/export/ExtendedArticleNativeXmlFilter.inc.php b/filter/export/ExtendedArticleNativeXmlFilter.inc.php index e54fe79..6c01aa1 100644 --- a/filter/export/ExtendedArticleNativeXmlFilter.inc.php +++ b/filter/export/ExtendedArticleNativeXmlFilter.inc.php @@ -117,14 +117,19 @@ public function addQueries($doc, $parentNode, $submission, $stageId) $queryDAO = DAORegistry::getDAO('QueryDAO'); $queries = $queryDAO->getByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), $stageId); - $queriesNode = $doc->createElementNS($deployment->getNamespace(), 'queries'); while ($query = $queries->next()) { + $participantIds = $queryDAO->getParticipantIds($query->getId()); + + if (empty($participantIds)) { + continue; + } + $queryNode = $doc->createElementNS($deployment->getNamespace(), 'query'); $queryNode->setAttribute('seq', $query->getData('sequence')); $queryNode->setAttribute('closed', (int) $query->getData('closed')); - $queryNode->appendChild($this->createQueryParticipantsNode($doc, $deployment, $query)); + $queryNode->appendChild($this->createQueryParticipantsNode($doc, $deployment, $participantIds)); $queryNode->appendChild($this->createQueryRepliesNode($doc, $deployment, $submission, $query)); $queriesNode->appendChild($queryNode); @@ -135,12 +140,10 @@ public function addQueries($doc, $parentNode, $submission, $stageId) } } - private function createQueryParticipantsNode($doc, $deployment, $query) + private function createQueryParticipantsNode($doc, $deployment, $participantIds) { - $queryDAO = DAORegistry::getDAO('QueryDAO'); $userDAO = DAORegistry::getDAO('UserDAO'); $participantsNode = $doc->createElementNS($deployment->getNamespace(), 'participants'); - $participantIds = $queryDAO->getParticipantIds($query->getId()); foreach ($participantIds as $participantId) { $participant = $userDAO->getById($participantId); @@ -162,6 +165,9 @@ private function createQueryRepliesNode($doc, $deployment, $submission, $query) while ($note = $replies->next()) { $user = $note->getUser(); + if (!$user) { + continue; + } $noteNode = $doc->createElementNS($deployment->getNamespace(), 'note'); $noteNode->setAttribute('user_email', htmlspecialchars($user->getEmail(), ENT_COMPAT, 'UTF-8')); $noteNode->setAttribute('date_modified', $note->getDateModified()); diff --git a/filter/import/NativeXmlExtendedArticleFilter.inc.php b/filter/import/NativeXmlExtendedArticleFilter.inc.php index 1d068e2..07351e5 100644 --- a/filter/import/NativeXmlExtendedArticleFilter.inc.php +++ b/filter/import/NativeXmlExtendedArticleFilter.inc.php @@ -209,8 +209,8 @@ public function parseQuery($node, $submission, $stageId) $deployment->setNote($note); $noteFilesNodes = $noteNode->getElementsByTagNameNS($deployment->getNamespace(), 'workflow_file'); - for ($i = 0; $i < $noteFilesNodes->count(); $i++) { - $noteNode = $noteFilesNodes->item($i); + for ($fileIndex = 0; $fileIndex < $noteFilesNodes->count(); $fileIndex++) { + $noteNode = $noteFilesNodes->item($fileIndex); $this->parseArticleFile($noteNode); } } diff --git a/fullJournal.xsd b/fullJournal.xsd index c0c838a..2d10e2f 100644 --- a/fullJournal.xsd +++ b/fullJournal.xsd @@ -394,7 +394,7 @@ - +