File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55### Fixed
66
7+ - Fix mobile devices duplication during mobile sync
78- Fix leftover data (profile rights and config values) after plugin uninstall
89
910## [ 3.2.2] - 2026-08-03
Original file line number Diff line number Diff line change @@ -720,12 +720,12 @@ public static function discover(): int
720720
721721 $ imported = [];
722722 $ iterator = $ DB ->request ([
723- 'SELECT ' => ['udid ' ],
723+ 'SELECT ' => ['jamf_items_id ' ],
724724 'FROM ' => 'glpi_plugin_jamf_devices ' ,
725725 'WHERE ' => ['jamf_type ' => static ::$ jamf_itemtype ],
726726 ]);
727727 foreach ($ iterator as $ data ) {
728- $ imported [] = $ data ['udid ' ];
728+ $ imported [] = ( int ) $ data ['jamf_items_id ' ];
729729 }
730730
731731 $ pending_iterator = $ DB ->request ([
@@ -742,7 +742,7 @@ public static function discover(): int
742742
743743 $ config = Config ::getConfigurationValues ('plugin:Jamf ' );
744744 foreach ($ jamf_devices as $ jamf_device ) {
745- if (!in_array ($ jamf_device ['id ' ], $ imported , true )) {
745+ if (!in_array (( int ) $ jamf_device ['id ' ], $ imported , true )) {
746746 $ itemtype = str_contains ((string ) $ jamf_device ['model_identifier ' ], 'iPhone ' ) ? 'Phone ' : 'Computer ' ;
747747 if (isset ($ config ['autoimport ' ]) && $ config ['autoimport ' ]) {
748748 try {
Original file line number Diff line number Diff line change @@ -193,6 +193,32 @@ public function testImportAsPhone()
193193 $ this ->assertEquals ('1aec6610a9401d2cc47cb55e1a2f7b500ab75864 ' , $ ext_field ['value ' ]);
194194 }
195195
196+ public function testDiscoverSkipsAlreadyImportedDevices ()
197+ {
198+ /** @var DBmysql $DB */
199+ global $ DB ;
200+
201+ // Ensure the device is imported (may already be done by a previous test)
202+ PluginJamfMobileTestSync ::import ('Phone ' , 5 , false );
203+ $ this ->assertGreaterThan (0 , countElementsInTable ('glpi_plugin_jamf_devices ' , [
204+ 'jamf_type ' => 'MobileDevice ' ,
205+ 'jamf_items_id ' => 5 ,
206+ ]));
207+
208+ $ DB ->delete (PluginJamfImport ::getTable (), ['jamf_type ' => 'MobileDevice ' ]);
209+ PluginJamfMobileTestSync ::discover ();
210+
211+ // The imported device must not be queued again for import
212+ $ this ->assertEquals (0 , countElementsInTable (PluginJamfImport ::getTable (), [
213+ 'jamf_type ' => 'MobileDevice ' ,
214+ 'jamf_items_id ' => 5 ,
215+ ]));
216+ // The other devices are still discovered
217+ $ this ->assertEquals (5 , countElementsInTable (PluginJamfImport ::getTable (), [
218+ 'jamf_type ' => 'MobileDevice ' ,
219+ ]));
220+ }
221+
196222 public static function deviceSyncEnginesProvider ()
197223 {
198224 $ engines = PluginJamfSync ::getDeviceSyncEngines ();
You can’t perform that action at this time.
0 commit comments