@@ -223,6 +223,43 @@ public function testHandleWithoutHistory(): void
223223 $ this ->assertSame ($ nb_logs , countElementsInTable (\Log ::getTable (), $ logs_criteria ));
224224 }
225225
226+ public function testHandleLongCommandLine (): void
227+ {
228+ $ this ->login ();
229+ $ conf = new Conf ();
230+ $ this ->assertTrue ($ conf ->saveConf ([
231+ 'import_process ' => 1 ,
232+ ]));
233+ $ this ->logout ();
234+
235+ $ computer = getItemByTypeName (Computer::class, '_test_pc01 ' );
236+
237+ $ converter = new Converter ();
238+ $ json = json_decode ($ converter ->convert ($ this ->assetProvider ()[0 ]['xml ' ]));
239+
240+ // command line exceeding the 65535 bytes of a TEXT column, see #25948
241+ $ cmd = '/usr/bin/java -cp ' . str_repeat ('/opt/app/lib/dependency.jar: ' , 3000 );
242+ $ this ->assertGreaterThan (65535 , strlen ($ cmd ));
243+ $ json ->content ->processes [0 ]->cmd = $ cmd ;
244+
245+ // inventory is played twice: existing process must be matched and updated
246+ for ($ i = 0 ; $ i < 2 ; $ i ++) {
247+ $ asset = new Process ($ computer , $ json ->content ->processes );
248+ $ asset ->setExtraData ((array ) $ json ->content );
249+ $ this ->assertTrue ($ asset ->checkConf ($ conf ));
250+ $ asset ->prepare ();
251+ $ asset ->handleLinks ();
252+ $ asset ->handle ();
253+ }
254+
255+ $ processes = getAllDataFromTable (
256+ \Item_Process ::getTable (),
257+ ['items_id ' => $ computer ->fields ['id ' ], 'itemtype ' => Computer::class]
258+ );
259+ $ this ->assertCount (1 , $ processes );
260+ $ this ->assertSame ($ cmd , current ($ processes )['cmd ' ]);
261+ }
262+
226263 public function testGenericAssetProcess (): void
227264 {
228265 global $ DB ;
0 commit comments