From bb80701f857401cf347144ff00ed3dae00d772ee Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Tue, 18 Jun 2024 15:59:18 +0200 Subject: [PATCH] pkp/pkp-lib#10082 Fix getTotalGalleyViews() --- classes/submission/Submission.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/submission/Submission.inc.php b/classes/submission/Submission.inc.php index 6433d28a3b..ad3b96289c 100644 --- a/classes/submission/Submission.inc.php +++ b/classes/submission/Submission.inc.php @@ -252,13 +252,15 @@ function getTotalGalleyViews() { $application = Application::get(); $publications = $this->getPublishedPublications(); $views = 0; + $fileIds = []; foreach ($publications as $publication) { foreach ((array) $publication->getData('galleys') as $galley) { $file = $galley->getFile(); - if (!$galley->getRemoteUrl() && $file) { + if (!$galley->getRemoteUrl() && $file && !in_array($file->getId(), $fileIds)) { $views = $views + $application->getPrimaryMetricByAssoc(ASSOC_TYPE_SUBMISSION_FILE, $file->getId()); - } + $fileIds[] = $file->getId(); + } } } return $views;