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
15 changes: 5 additions & 10 deletions install/empty_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -4610,34 +4610,29 @@ public function getEmptyData(): array
'id' => '187',
'items_id' => '1',
'type' => '1',
'notifications_id' => '71',
], [
'id' => '188',
'items_id' => '1',
'type' => '1',
'notifications_id' => '72',
], [
'id' => '189',
'id' => '188',
'items_id' => '1',
'type' => '1',
'notifications_id' => '74',
], [
'id' => '190',
'id' => '189',
'items_id' => '1',
'type' => '1',
'notifications_id' => '75',
], [
'id' => '191',
'id' => '190',
'items_id' => '1',
'type' => '1',
'notifications_id' => '80',
], [
'id' => '192',
'id' => '191',
'items_id' => '1',
'type' => '1',
'notifications_id' => '81',
], [
'id' => '193',
'id' => '192',
'items_id' => '1',
'type' => '1',
'notifications_id' => '82',
Expand Down
72 changes: 72 additions & 0 deletions install/migrations/update_11.0.5_to_11.0.6.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

/**
* ---------------------------------------------------------------------
*
* GLPI - Gestionnaire Libre de Parc Informatique
*
* http://glpi-project.org
*
* @copyright 2015-2026 Teclib' and contributors.
* @licence https://www.gnu.org/licenses/gpl-3.0.html
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* ---------------------------------------------------------------------
*/

use function Safe\preg_match;
use function Safe\scandir;

/**
* Update from 11.0.5 to 11.0.6
*
* @return bool for success (will die for most error)
**/
function update1105to1106()
{
/**
* @var DBmysql $DB
* @var Migration $migration
*/
global $DB, $migration;

$updateresult = true;
$ADDTODISPLAYPREF = [];
$DELFROMDISPLAYPREF = [];
$update_dir = __DIR__ . '/update_11.0.5_to_11.0.6/';

$migration->setVersion('11.0.6');

$update_scripts = scandir($update_dir);
foreach ($update_scripts as $update_script) {
if (preg_match('/\.php$/', $update_script) !== 1) {
continue;
}
require $update_dir . $update_script;
}

// ************ Keep it at the end **************
$migration->updateDisplayPrefs($ADDTODISPLAYPREF, $DELFROMDISPLAYPREF);

$migration->executeMigration();

return $updateresult;
}
64 changes: 64 additions & 0 deletions install/migrations/update_11.0.5_to_11.0.6/notificationtargets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/**
* ---------------------------------------------------------------------
*
* GLPI - Gestionnaire Libre de Parc Informatique
*
* http://glpi-project.org
*
* @copyright 2015-2026 Teclib' and contributors.
* @licence https://www.gnu.org/licenses/gpl-3.0.html
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* ---------------------------------------------------------------------
*/

/**
* @var DBmysql $DB
* @var Migration $migration
*/

// Remove duplicates targets
$duplicates_targets_iterator = $DB->request([
'SELECT' => [
'notifications_id',
'items_id',
'type',
'MIN' => 'id AS min_id',
'COUNT' => '* AS count',
],
'FROM' => 'glpi_notificationtargets',
'GROUPBY' => ['notifications_id', 'items_id', 'type'],
'HAVING' => ['count' => ['>', 1]],
]);

foreach ($duplicates_targets_iterator as $target) {
$DB->delete('glpi_notificationtargets', [
'notifications_id' => $target['notifications_id'],
'items_id' => $target['items_id'],
'type' => $target['type'],
'id' => ['>', $target['min_id']],
]);
}

$migration->dropKey('glpi_notificationtargets', 'notifications_id');
$migration->addKey('glpi_notificationtargets', ['notifications_id', 'items_id', 'type'], 'unicity', 'UNIQUE');
2 changes: 1 addition & 1 deletion install/mysql/glpi-empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5075,8 +5075,8 @@ CREATE TABLE `glpi_notificationtargets` (
`notifications_id` int unsigned NOT NULL DEFAULT '0',
`is_exclusion` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`notifications_id`,`items_id`,`type`),
KEY `items` (`type`,`items_id`),
KEY `notifications_id` (`notifications_id`),
KEY `is_exclusion` (`is_exclusion`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

Expand Down