2828 * -------------------------------------------------------------------------
2929 */
3030
31+ use function Safe \json_decode ;
32+ use function Safe \json_encode ;
3133use function Safe \ob_start ;
3234use function Safe \ob_get_clean ;
3335use function Safe \preg_match ;
@@ -95,8 +97,9 @@ public static function getSpecificValueToDisplay($field, $values, array $options
9597 $ value = ' ' ;
9698 $ out = ' ' ;
9799 if (!str_contains ((string ) $ values ['id ' ], Search::NULLVALUE )) {
98- $ search_params = Search::manageParams ('Computer ' ,
99- json_decode ($ values ['search ' ], true , 512 , JSON_THROW_ON_ERROR )
100+ $ search_params = Search::manageParams (
101+ 'Computer ' ,
102+ json_decode ((string ) $ values ['search ' ], true , 512 , JSON_THROW_ON_ERROR ),
100103 );
101104
102105
@@ -164,8 +167,9 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
164167
165168 private function countDynamicItems ()
166169 {
167- $ search_params = Search::manageParams ('Computer ' ,
168- json_decode ($ this ->fields ['search ' ], true , 512 , JSON_THROW_ON_ERROR )
170+ $ search_params = Search::manageParams (
171+ 'Computer ' ,
172+ json_decode ((string ) $ this ->fields ['search ' ], true , 512 , JSON_THROW_ON_ERROR ),
169173 );
170174
171175 $ data = Search::prepareDatasForSearch ('Computer ' , $ search_params );
@@ -178,7 +182,7 @@ private function countDynamicItems()
178182 public function isDynamicSearchMatchComputer (Computer $ computer )
179183 {
180184 // add new criteria to force computer ID
181- $ search = json_decode ($ this ->fields ['search ' ]);
185+ $ search = json_decode (( string ) $ this ->fields ['search ' ]);
182186
183187 $ search ['criteria ' ][] = [
184188 'link ' => 'AND ' ,
@@ -214,8 +218,9 @@ private static function showForItem(PluginDatabaseinventoryComputerGroup $comput
214218 if ($ computergroup_dynamic ->getFromDBByCrit ([
215219 'plugin_databaseinventory_computergroups_id ' => $ ID ,
216220 ])) {
217- $ p = Search::manageParams ('Computer ' ,
218- json_decode ($ computergroup_dynamic ->fields ['search ' ], true , 512 , JSON_THROW_ON_ERROR )
221+ $ p = Search::manageParams (
222+ 'Computer ' ,
223+ json_decode ((string ) $ computergroup_dynamic ->fields ['search ' ], true , 512 , JSON_THROW_ON_ERROR ),
219224 );
220225
221226 $ search_params = $ p ;
@@ -310,17 +315,17 @@ public static function install(Migration $migration)
310315 if ($ unserialized !== false ) {
311316 $ json_search = json_encode ($ unserialized , JSON_THROW_ON_ERROR );
312317 }
313- } catch (Throwable $ e ) {
318+ } catch (Throwable ) {
314319 $ migration ->displayMessage (
315- " DatabaseInventory - Invalid serialized data for DynamicGroup ID { $ id } , data will be reset. "
320+ sprintf ( ' DatabaseInventory - Invalid serialized data for DynamicGroup ID %s , data will be reset. ' , $ id ),
316321 );
317322 continue ;
318323 }
319324
320325 $ DB ->update (
321326 $ table ,
322327 ['search ' => $ json_search ],
323- ['id ' => $ id ]
328+ ['id ' => $ id ],
324329 );
325330 }
326331
0 commit comments