Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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

- Fix dashboard crash when adding a report without selecting one (invalid `reports_id` value)

## [1.9.5] - 2026-05-12

### Fixed
Expand Down
8 changes: 5 additions & 3 deletions front/dashboard.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@

Html::back();
} elseif (isset($_POST['addReports'])) {
$dashboard = new PluginMreportingDashboard();
$post = ['users_id' => $_SESSION['glpiID'], 'reports_id' => $_POST['report']];
$dashboard->add($post);
$report_id = (int) ($_POST['report'] ?? 0);
if ($report_id > 0) {
$dashboard = new PluginMreportingDashboard();
$dashboard->add(['users_id' => $_SESSION['glpiID'], 'reports_id' => $report_id]);
}

Html::back();
} else {
Expand Down
10 changes: 10 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ function plugin_mreporting_install()
$migration->addField('glpi_plugin_mreporting_preferences', 'selectors', 'text');
$migration->migrationOneTable('glpi_plugin_mreporting_preferences');

// == Fix dashboard entries with invalid reports_id (e.g. -1 from empty dropdown selection)
$DB->delete('glpi_plugin_mreporting_dashboards', ['reports_id' => ['<=', 0]]);
$migration->changeField(
'glpi_plugin_mreporting_dashboards',
'reports_id',
'reports_id',
"int {$default_key_sign} NOT NULL",
);
$migration->migrationOneTable('glpi_plugin_mreporting_dashboards');

// == Init available reports
require_once __DIR__ . '/inc/baseclass.class.php';
require_once __DIR__ . '/inc/common.class.php';
Expand Down