diff --git a/CHANGELOG.md b/CHANGELOG.md index 10ba048..4b32c65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Fix `Clear` checkbox not erasing the stored SCCM database password and inventory credentials +- Fix inventoried BIOS date, volume names and LastHWScan time, stop sending slot labels as memory type - CI: fix Psalm cache directory, drop the stray `glpi-project/tools` composer dependency, declare a unique composer autoloader suffix ## [2.6.1] - 2026-08-04 diff --git a/inc/sccm.class.php b/inc/sccm.class.php index 3a157d8..21ea71c 100644 --- a/inc/sccm.class.php +++ b/inc/sccm.class.php @@ -200,7 +200,6 @@ public function getMemories(PluginSccmSccmdb $sccm_db, $deviceid, $limit = 99999 Removable0 as \"Mem-Removable\", '' as \"Mem-Purpose\", Speed0 as \"Mem-Speed\", - BankLabel0 as \"Mem-Type\", GroupID as \"Mem-NumSlots\", '' as \"Mem-SerialNumber\" FROM v_GS_PHYSICAL_MEMORY @@ -648,7 +647,7 @@ public static function executePush(CronTask $task): int if ($asset->getFromDB($agent->fields['items_id'])) { $asset->update([ "id" => $asset->fields['id'], - "last_inventory_update" => $tab['vWD-LastScan']->format('Y-m-d h:i'), + "last_inventory_update" => $tab['vWD-LastScan']->format('Y-m-d H:i'), ]); } } diff --git a/inc/sccmxml.class.php b/inc/sccmxml.class.php index 7a03547..7740e1e 100644 --- a/inc/sccmxml.class.php +++ b/inc/sccmxml.class.php @@ -70,7 +70,7 @@ public function setAccessLog(): void $CONTENT->addChild('ACCESSLOG'); $ACCESSLOG = $this->sxml->CONTENT[0]->ACCESSLOG; - $ACCESSLOG->addChild('LOGDATE', date('Y-m-d h:i:s')); + $ACCESSLOG->addChild('LOGDATE', date('Y-m-d H:i:s')); if (!empty($this->data['VrS-UserName'])) { $this->username = $this->data['VrS-UserName']; @@ -151,7 +151,7 @@ public function setBios(): void } if ($Date_Sccm != false) { - $this->data['PBD-ReleaseDate'] = $Date_Sccm->format('m/d/Y'); + $this->data['PBD-ReleaseDate'] = $Date_Sccm->format('Y-m-d'); } $BIOS->addChild('BDATE', $this->data['PBD-ReleaseDate']); @@ -252,7 +252,6 @@ public function setMemories(PluginSccmSccmdb $sccm_db, ?PluginSccmSccm $sccm = n $MEMORIES->addChild('REMOVABLE', $value['Mem-Removable']); $MEMORIES->addChild('PURPOSE', $value['Mem-Purpose']); $MEMORIES->addChild('SPEED', $value['Mem-Speed']); - $MEMORIES->addChild('TYPE', $value['Mem-Type']); $MEMORIES->addChild('NUMSLOTS', $value['Mem-NumSlots']); $MEMORIES->addChild('SERIALNUMBER', $value['Mem-SerialNumber']); $MEMORIES->addChild('MANUFACTURER', $value['Mem-Manufacturer']); @@ -394,8 +393,8 @@ public function setStorages(PluginSccmSccmdb $sccm_db, ?PluginSccmSccm $sccm = n $DRIVES->addChild('DESCRIPTION', $value['gld-Description']); $DRIVES->addChild('FILESYSTEM', $value['gld-FileSystem']); $DRIVES->addChild('FREE', $value['gld-FreeSpace']); - $DRIVES->addChild('LABEL', $value['gdi-Caption']); - $DRIVES->addChild('LETTER', $value['gld-MountingPoint']); + $DRIVES->addChild('LABEL', $value['gld-MountingPoint']); + $DRIVES->addChild('LETTER', $value['gld-Partition']); $DRIVES->addChild('TOTAL', $value['gld-TotalSize']); $DRIVES->addChild('VOLUMN', $value['gld-Partition']); $i++; diff --git a/tests/PluginSccmSccmxmlTest.php b/tests/PluginSccmSccmxmlTest.php index fea7025..433876e 100644 --- a/tests/PluginSccmSccmxmlTest.php +++ b/tests/PluginSccmSccmxmlTest.php @@ -126,9 +126,11 @@ public function testSetBiosNormalizesReleaseDate(mixed $releaseDate, string $exp public static function biosDateProvider(): iterable { - yield 'valid string date' => ['Jan 01 2020', '01/01/2020']; - yield 'end of year string date' => ['Dec 31 1999', '12/31/1999']; - yield 'DateTime object' => [new DateTime('2020-06-15'), '06/15/2020']; + yield 'valid string date' => ['Jan 01 2020', '2020-01-01']; + yield 'end of year string date' => ['Dec 31 1999', '1999-12-31']; + // Swapped to 2025-02-05 by GLPI when sent as m/d/Y + yield 'day above 12' => ['May 14 2024', '2024-05-14']; + yield 'DateTime object' => [new DateTime('2020-06-15'), '2020-06-15']; yield 'invalid string preserved as-is' => ['invalid-date', 'invalid-date']; } @@ -370,4 +372,51 @@ public function testSetStoragesMultipliesSizeBy1024(): void $this->assertSame('524288', (string) $drive->TOTAL); $this->assertSame('131072', (string) $drive->FREE); } + + public function testSetStoragesMapsVolumeFields(): void + { + $sccm = $this->makeSccmMock('getStorages', 'getMedias'); + $sccm->method('getStorages')->willReturn([[ + 'gld-TotalSize' => '512', + 'gld-FreeSpace' => '128', + 'gld-Description' => 'Local Fixed Disk', + 'gld-Partition' => 'C:', + 'gld-FileSystem' => 'NTFS', + 'gld-MountingPoint' => 'OS', + 'gdi-Caption' => 'SAMSUNG MZVL2512HCJQ', + ]]); + $sccm->method('getMedias')->willReturn([]); + $this->xml->device_id = 'test-device'; + + $this->xml->setStorages($this->makeSccmDbMock(), $sccm); + + $drive = $this->xml->sxml->CONTENT[0]->DRIVES[0]; + $this->assertSame('C:', (string) $drive->LETTER); + $this->assertSame('OS', (string) $drive->LABEL); + $this->assertSame('C:', (string) $drive->VOLUMN); + } + + public function testSetMemoriesDoesNotSendSlotLabelAsType(): void + { + $sccm = $this->makeSccmMock('getMemories'); + $sccm->method('getMemories')->willReturn([[ + 'Mem-Capacity' => '16384', + 'Mem-Caption' => 'Physical Memory', + 'Mem-Description' => 'Physical Memory', + 'Mem-FormFactor' => '12', + 'Mem-Manufacturer' => 'Samsung', + 'Mem-Removable' => '0', + 'Mem-Purpose' => '', + 'Mem-Speed' => '5200', + 'Mem-NumSlots' => '1', + 'Mem-SerialNumber' => '', + ]]); + $this->xml->device_id = 'test-device'; + + $this->xml->setMemories($this->makeSccmDbMock(), $sccm); + + $memory = $this->xml->sxml->CONTENT[0]->MEMORIES[0]; + $this->assertSame('16384', (string) $memory->CAPACITY); + $this->assertFalse(isset($memory->TYPE)); + } }