From 7b27652038ae5e876b4d7306f5432e586dbb345a Mon Sep 17 00:00:00 2001 From: mbressy Date: Tue, 5 May 2026 07:45:35 +0000 Subject: [PATCH 1/2] prevent service catalog crash --- inc/alert.class.php | 12 ++++++++++++ setup.php | 11 +++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/inc/alert.class.php b/inc/alert.class.php index a965f63..806e4b9 100644 --- a/inc/alert.class.php +++ b/inc/alert.class.php @@ -542,9 +542,21 @@ public static function displayOnTicket() public static function displayOnServiceCatalog() { + if (!self::hasServiceCatalogDisplayFlag()) { + return; + } + self::displayAlerts(['show_only_service_catalog_alerts' => true]); } + private static function hasServiceCatalogDisplayFlag(): bool + { + /** @var DBmysql $DB */ + global $DB; + + return $DB->fieldExists(self::getTable(), 'is_displayed_onservicecatalog'); + } + public static function displayAlerts($params = []) { /** @var array $CFG_GLPI */ diff --git a/setup.php b/setup.php index bde7b69..039dde8 100644 --- a/setup.php +++ b/setup.php @@ -42,8 +42,9 @@ function plugin_init_news() /** * @var array $PLUGIN_HOOKS * @var array $CFG_GLPI + * @var DBmysql $DB */ - global $PLUGIN_HOOKS, $CFG_GLPI; + global $PLUGIN_HOOKS, $CFG_GLPI, $DB; $PLUGIN_HOOKS['csrf_compliant']['news'] = true; @@ -62,9 +63,11 @@ function plugin_init_news() $PLUGIN_HOOKS['display_central']['news'] = [ 'PluginNewsAlert', 'displayOnCentral', ]; - $PLUGIN_HOOKS['display_service_catalog']['news'] = [ - 'PluginNewsAlert', 'displayOnServiceCatalog', - ]; + if ($DB->fieldExists(PluginNewsAlert::getTable(), 'is_displayed_onservicecatalog')) { + $PLUGIN_HOOKS['display_service_catalog']['news'] = [ + 'PluginNewsAlert', 'displayOnServiceCatalog', + ]; + } $PLUGIN_HOOKS['pre_item_list']['news'] = ['PluginNewsAlert', 'preItemList']; $PLUGIN_HOOKS['pre_item_form']['news'] = ['PluginNewsAlert', 'preItemForm']; From 4a0ce9472b20c938ce329d355743a958f9977bc6 Mon Sep 17 00:00:00 2001 From: mbressy Date: Tue, 5 May 2026 07:51:09 +0000 Subject: [PATCH 2/2] update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e72bab..55834ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Fixed + +- Prevent a crash on the service catalog page when plugin files are updated before the database schema migration is applied. + ## [1.14.0] - 2026-04-30 ### Added