Skip to content

Commit

Permalink
Minor improvements to UpgradeController. (#3801)
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Jun 13, 2024
1 parent 6fc6df2 commit 2bc5a91
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions module/VuFind/src/VuFind/Controller/UpgradeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,8 @@ public function fixmetadataAction()
set_time_limit(0);

// Check for problems:
$problems = $this->getDbService(ResourceServiceInterface::class)->findMissingMetadata();
$resourceService = $this->getDbService(ResourceServiceInterface::class);
$problems = $resourceService->findMissingMetadata();

// No problems? We're done here!
if (count($problems) == 0) {
Expand All @@ -794,18 +795,22 @@ public function fixmetadataAction()

// Process submit button:
if ($this->formWasSubmitted()) {
$resourceService = $this->getDbService(ResourceServiceInterface::class);
$resourcePopulator = $this->serviceLocator->get(ResourcePopulator::class);
foreach ($problems as $problem) {
$recordId = $problem->getRecordId();
$source = $problem->getSource();
try {
$driver = $this->getRecordLoader()->load($problem->getRecordId(), $problem->getSource());
$driver = $this->getRecordLoader()->load($recordId, $source);
$resourceService->persistEntity(
$resourcePopulator->assignMetadata($problem, $driver)
);
} catch (RecordMissingException $e) {
$this->session->warnings->append(
'Unable to load metadata for record '
. "{$problem->getSource()}:{$problem->getRecordId()}"
"Unable to load metadata for record {$source}:{$recordId}"
);
} catch (\Exception $e) {
$this->session->warnings->append(
"Problem saving metadata updates for record {$source}:{$recordId}"
);
}
}
Expand Down

0 comments on commit 2bc5a91

Please sign in to comment.