diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b77386..769eac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [UNRELEASED] +## [1.1.2] - 2025-11-25 + ### Fixed -- Fix dynamic group submit bouton +- Migrate dynamic group search from serialized to JSON format +- Fix dynamic group submit button + +## [1.0.5] - 2025-11-25 + +### Fixed + +- Migrate dynamic group search from serialized to JSON format +- Fix `Undefined array key "id"` when computer not already linkedo agent ## [1.1.1] - 2025-11-13 @@ -23,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - GLPI 11 compatibility + ### Fixed - Fix `Undefined array key "id"` when computer not already linkedo agent diff --git a/databaseinventory.xml b/databaseinventory.xml index 08b363e..3228d85 100644 --- a/databaseinventory.xml +++ b/databaseinventory.xml @@ -21,6 +21,16 @@ Teclib' + + 1.1.2 + ~11.0.0 + https://github.com/pluginsGLPI/databaseinventory/releases/download/1.1.2/glpi-databaseinventory-1.1.2.tar.bz2 + + + 1.0.5 + ~10.0.0 + https://github.com/pluginsGLPI/databaseinventory/releases/download/1.0.5/glpi-databaseinventory-1.0.5.tar.bz2 + 1.1.1 ~11.0.0 diff --git a/inc/computergroup.class.php b/inc/computergroup.class.php index fd5dd1f..cadb3f6 100644 --- a/inc/computergroup.class.php +++ b/inc/computergroup.class.php @@ -199,7 +199,7 @@ public function countDynamicItem() $iterator = $DB->request($params); foreach ($iterator as $computergroup_dynamic) { - $search_params = Search::manageParams('Computer', json_decode($computergroup_dynamic['search'], true, 512, JSON_THROW_ON_ERROR)); + $search_params = Search::manageParams('Computer', json_decode((string) $computergroup_dynamic['search'], true, 512, JSON_THROW_ON_ERROR)); $data = Search::prepareDatasForSearch('Computer', $search_params); Search::constructSQL($data); Search::constructData($data); diff --git a/inc/computergroupdynamic.class.php b/inc/computergroupdynamic.class.php index 7e33df5..bb80312 100644 --- a/inc/computergroupdynamic.class.php +++ b/inc/computergroupdynamic.class.php @@ -28,6 +28,8 @@ * ------------------------------------------------------------------------- */ +use function Safe\json_decode; +use function Safe\json_encode; use function Safe\ob_start; use function Safe\ob_get_clean; use function Safe\preg_match; @@ -95,8 +97,9 @@ public static function getSpecificValueToDisplay($field, $values, array $options $value = ' '; $out = ' '; if (!str_contains((string) $values['id'], Search::NULLVALUE)) { - $search_params = Search::manageParams('Computer', - json_decode($values['search'], true, 512, JSON_THROW_ON_ERROR) + $search_params = Search::manageParams( + 'Computer', + json_decode((string) $values['search'], true, 512, JSON_THROW_ON_ERROR), ); @@ -164,8 +167,9 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ private function countDynamicItems() { - $search_params = Search::manageParams('Computer', - json_decode($this->fields['search'], true, 512, JSON_THROW_ON_ERROR) + $search_params = Search::manageParams( + 'Computer', + json_decode((string) $this->fields['search'], true, 512, JSON_THROW_ON_ERROR), ); $data = Search::prepareDatasForSearch('Computer', $search_params); @@ -178,7 +182,7 @@ private function countDynamicItems() public function isDynamicSearchMatchComputer(Computer $computer) { // add new criteria to force computer ID - $search = json_decode($this->fields['search']); + $search = json_decode((string) $this->fields['search']); $search['criteria'][] = [ 'link' => 'AND', @@ -214,8 +218,9 @@ private static function showForItem(PluginDatabaseinventoryComputerGroup $comput if ($computergroup_dynamic->getFromDBByCrit([ 'plugin_databaseinventory_computergroups_id' => $ID, ])) { - $p = Search::manageParams('Computer', - json_decode($computergroup_dynamic->fields['search'], true, 512, JSON_THROW_ON_ERROR) + $p = Search::manageParams( + 'Computer', + json_decode((string) $computergroup_dynamic->fields['search'], true, 512, JSON_THROW_ON_ERROR), ); $search_params = $p; @@ -310,9 +315,9 @@ public static function install(Migration $migration) if ($unserialized !== false) { $json_search = json_encode($unserialized, JSON_THROW_ON_ERROR); } - } catch (Throwable $e) { + } catch (Throwable) { $migration->displayMessage( - "DatabaseInventory - Invalid serialized data for DynamicGroup ID {$id}, data will be reset." + sprintf('DatabaseInventory - Invalid serialized data for DynamicGroup ID %s, data will be reset.', $id), ); continue; } @@ -320,7 +325,7 @@ public static function install(Migration $migration) $DB->update( $table, ['search' => $json_search], - ['id' => $id] + ['id' => $id], ); } diff --git a/setup.php b/setup.php index 41cd064..43bbc5d 100644 --- a/setup.php +++ b/setup.php @@ -30,7 +30,7 @@ use function Safe\define; -define('PLUGIN_DATABASEINVENTORY_VERSION', '1.1.1'); +define('PLUGIN_DATABASEINVENTORY_VERSION', '1.1.2'); // Minimal GLPI version, inclusive define('PLUGIN_DATABASEINVENTORY_MIN_GLPI', '11.0.0'); // Maximum GLPI version, exclusive