Skip to content

Commit fdbe5ee

Browse files
committed
Fix glpi_softwarelicenses.is_valid 0.85 migration
1 parent b5e747f commit fdbe5ee

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

install/migrations/update_0.84.x_to_0.85.0.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,10 +2922,30 @@ function update084xto0850()
29222922
FROM `glpi_softwarelicenses`";
29232923

29242924
foreach ($DB->request($queryl) as $datal) {
2925-
if (
2926-
($datal['number'] >= 0)
2927-
&& ($datal['number'] < Item_SoftwareLicense::countForLicense($datal['id'], -1, 'Computer'))
2928-
) {
2925+
if (!($datal['number'] >= 0)) {
2926+
continue;
2927+
}
2928+
2929+
$count_for_license = $DB->request([
2930+
'FROM' => 'glpi_computers_softwarelicenses',
2931+
'COUNT' => 'cpt',
2932+
'INNER JOIN' => [
2933+
'glpi_computers' => [
2934+
'FKEY' => [
2935+
'glpi_computers' => 'id',
2936+
'glpi_computers_softwarelicenses' => 'computers_id'
2937+
]
2938+
]
2939+
],
2940+
'WHERE' => [
2941+
'glpi_computers_softwarelicenses.softwarelicenses_id' => $datal['id'],
2942+
'glpi_computers.is_deleted' => 0,
2943+
'glpi_computers.is_template' => 0,
2944+
'glpi_computers_softwarelicenses.is_deleted' => 0
2945+
]
2946+
])->current()['cpt'];
2947+
2948+
if ($datal['number'] < $count_for_license) {
29292949
$queryl2 = "UPDATE `glpi_softwarelicenses`
29302950
SET `is_valid` = 0
29312951
WHERE `id` = '" . $datal['id'] . "'";

0 commit comments

Comments
 (0)