Merge pull request #3895 from Icinga/fix/dashboard-migration-requires-all-locales

Don't fail dashboard migration just because a locale is missing
This commit is contained in:
Johannes Meyer 2019-08-12 13:33:07 +02:00 committed by GitHub
commit b0875d40f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 5 deletions

View File

@ -9,6 +9,7 @@ use Icinga\Application\Icinga;
use Icinga\Application\Modules\DashboardContainer; use Icinga\Application\Modules\DashboardContainer;
use Icinga\Cli\Command; use Icinga\Cli\Command;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Exception\IcingaException;
use Icinga\Util\Translator; use Icinga\Util\Translator;
use ReflectionClass; use ReflectionClass;
@ -58,7 +59,12 @@ class DashboardCommand extends Command
continue; continue;
} }
Translator::setupLocale($locale); try {
Translator::setupLocale($locale);
} catch (IcingaException $e) {
Logger::debug('Ignoring locale "%s". Reason: %s', $locale, $e->getMessage());
continue;
}
foreach ($paneItemsProperty->getValue($module) as $paneName => $container) { foreach ($paneItemsProperty->getValue($module) as $paneName => $container) {
/** @var DashboardContainer $container */ /** @var DashboardContainer $container */
@ -70,10 +76,7 @@ class DashboardCommand extends Command
$dashletTitle = null; $dashletTitle = null;
} }
if (isset($options['disabled']) && mt($module->getName(), $paneName) !== $paneTitle) { if (mt($module->getName(), $paneName) !== $paneTitle) {
// `disabled` is checked because if it's a module's pane that's the only reason
// why it's in there. If a user utilized the same label though for a custom pane,
// it remains as is.
continue; continue;
} }
@ -85,6 +88,10 @@ class DashboardCommand extends Command
break; break;
} }
} }
if ($dashletName === null) {
$dashletName = $dashletTitle;
}
} }
$newSection = $paneName . ($dashletName ? '.' . $dashletName : ''); $newSection = $paneName . ($dashletName ? '.' . $dashletName : '');