Handle incomplete OAI plugin configuration

Don't throw an exception when $library is null because the OAI
plugin was not configured, but use the default values for oai_label
and contact.

That makes the code more robust and helps admins who install
Kitodo.Presentation.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2022-10-13 16:04:37 +02:00
parent 139eb51fc6
commit 9c5485206b
1 changed files with 2 additions and 2 deletions

View File

@ -387,14 +387,14 @@ class OaiPmhController extends AbstractController
$this->logger->notice('Incomplete plugin configuration');
}
$oaiIdentifyInfo['oai_label'] = $library->getOaiLabel();
$oaiIdentifyInfo['oai_label'] = $library ? $library->getOaiLabel() : '';
// Use default values for an installation with incomplete plugin configuration.
if (empty($oaiIdentifyInfo['oai_label'])) {
$oaiIdentifyInfo['oai_label'] = 'Kitodo.Presentation OAI-PMH Interface (default configuration)';
$this->logger->notice('Incomplete plugin configuration (oai_label is missing)');
}
$oaiIdentifyInfo['contact'] = $library->getContact();
$oaiIdentifyInfo['contact'] = $library ? $library->getContact() : '';
if (empty($oaiIdentifyInfo['contact'])) {
$oaiIdentifyInfo['contact'] = 'unknown@example.org';
$this->logger->notice('Incomplete plugin configuration (contact is missing)');