Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions inc/sccm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'),
]);
}
}
Expand Down
9 changes: 4 additions & 5 deletions inc/sccmxml.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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++;
Expand Down
55 changes: 52 additions & 3 deletions tests/PluginSccmSccmxmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}

Expand Down Expand Up @@ -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));
}
}
Loading