Skip to content

Commit

Permalink
pkp#9425 Fixes omp crash
Browse files Browse the repository at this point in the history
  • Loading branch information
jyhein committed Oct 31, 2023
1 parent cdbe159 commit d837ad6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 10 additions & 3 deletions classes/submissionFile/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,16 @@ protected function mapByProperties(array $props, SubmissionFile $submissionFile)
$output[$prop] = $submissionFile->getData($prop);
}

$publicationId = $submissionFile->getData('assocId') ? Repo::galley()->get($submissionFile->getData('assocId'))?->getData('publicationId') : null;
$publicationLocales = $publicationId ? Repo::publication()->get($publicationId)?->getLanguages() ?? [] : [];
$locales = array_values(array_unique(array_merge($this->context->getSupportedSubmissionMetadataLocales(), $publicationLocales, [$submissionFile->getData('locale')])));
$publicationLocales = !($assocId = $submissionFile->getData('assocId'))
? [$submissionFile->getData('locale')]
: Repo::submission()
->get($submissionFile->getData('submissionId'))
->getData('publications')
->first(fn ($p) => collect($p->getData(Application::get()->getName() === 'omp' ? 'publicationFormats' : 'galleys'))
->contains(fn ($item) => $item->getId() === $submissionFile->getData('assocId')))
->getLanguages();

$locales = array_values(array_unique(array_merge($this->context->getSupportedSubmissionMetadataLocales(), $publicationLocales)));

$output = $this->schemaService->addMissingMultilingualValues(
$this->schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ public function __construct($submissionFile, $stageId, $reviewRound = null, $tem
}

$submissionLocale = $submissionFile->getData('locale');
$publicationLocaleNames = Repo::publication()->get(Repo::galley()->get($submissionFile->getData('assocId'))?->getData('publicationId'))?->getLanguageNames() ?? [];
$publicationLocaleNames = Repo::submission()
->get($submissionFile->getData('submissionId'))
->getData('publications')
->first(fn ($p) => collect($p->getData(Application::get()->getName() === 'omp' ? 'publicationFormats' : 'galleys'))
->contains(fn ($item) => $item->getId() === $submissionFile->getData('assocId')))
->getLanguageNames();
$localeNames = Application::get()->getRequest()->getContext()->getSupportedSubmissionMetadataLocaleNames() + $publicationLocaleNames;
ksort($localeNames);

Expand Down

0 comments on commit d837ad6

Please sign in to comment.