diff --git a/CHANGELOG.md b/CHANGELOG.md index bb711d8..f65d2c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] + +### Fixed + +- Faster display of pages showing alerts (ticket form, central page, ticket list) when many alerts exist +- Faster display of the alert targets tab +- Closing an alert sent one request per tab previously opened on the page + ## [1.14.3] - 2026-11-05 ### Fixed diff --git a/hook.php b/hook.php index a700358..31ce553 100644 --- a/hook.php +++ b/hook.php @@ -157,6 +157,9 @@ function plugin_news_install() $migration->addKey($alert_table, 'is_active'); } + // index used to find the alerts to display, which would otherwise scan every past alert + $migration->addKey($alert_table, ['is_active', 'is_deleted', 'date_end'], 'is_active_is_deleted_date_end'); + // fix is_default default value $alert_fields = $DB->listFields($alert_table); if ($alert_fields['is_deleted']['Default'] !== '0') { diff --git a/inc/alert.class.php b/inc/alert.class.php index a4a5809..5f24f2b 100644 --- a/inc/alert.class.php +++ b/inc/alert.class.php @@ -227,24 +227,18 @@ public function rawSearchOptions() public function post_updateItem($history = true) { + /** @var DBmysql $DB */ + global $DB; + // force display of alerts after update regardless of their closable state - $alert_user = new PluginNewsAlert_User(); - //get all Alert_User for this alert where state is hidden - $all_alert = $alert_user->find( + $DB->update( + PluginNewsAlert_User::getTable(), + ['state' => PluginNewsAlert_User::VISIBLE], [ 'plugin_news_alerts_id' => $this->getID(), 'state' => PluginNewsAlert_User::HIDDEN, ], ); - foreach ($all_alert as $alert) { - //update state to force display - $alert_user->update( - [ - 'id' => $alert['id'], - 'state' => PluginNewsAlert_User::VISIBLE, - ], - ); - } } public static function findAllToNotify($params = []) diff --git a/inc/alert_target.class.php b/inc/alert_target.class.php index ded9ff2..213024f 100644 --- a/inc/alert_target.class.php +++ b/inc/alert_target.class.php @@ -120,8 +120,11 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ public static function showForAlert(PluginNewsAlert $alert) { - /** @var array $CFG_GLPI */ - global $CFG_GLPI; + /** + * @var array $CFG_GLPI + * @var DBmysql $DB + */ + global $CFG_GLPI, $DB; $rand = mt_rand(); echo "