From 594b4c979e41fc74ce26c35907e449cda7b455c8 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:31:54 +0200 Subject: [PATCH 1/9] Fix(core): Uninstall profile right --- hook.php | 2 ++ inc/profile.class.php | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/hook.php b/hook.php index af4e28f..4eae3c7 100644 --- a/hook.php +++ b/hook.php @@ -98,8 +98,10 @@ function plugin_uninstall_uninstall() require_once($dir . "/inc/config.class.php"); PluginUninstallProfile::uninstall(); + PluginUninstallProfile::deleteProfileRights([PluginUninstallProfile::RIGHT_REPLACE]); PluginUninstallModel::uninstall(); PluginUninstallPreference::uninstall(); PluginUninstallConfig::uninstall(); + return true; } diff --git a/inc/profile.class.php b/inc/profile.class.php index 9cb7331..c3b295e 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -305,4 +305,24 @@ public static function uninstall() $DB->doQuery("DROP TABLE IF EXISTS `" . getTableForItemType(self::class) . "`"); } + + public static function deleteProfileRights(array $rights) + { + global $DB, $GLPI_CACHE; + + $GLPI_CACHE->set('all_possible_rights', []); + $ok = true; + foreach ($rights as $name) { + $result = $DB->delete( + self::getTable(), + [ + 'name' => $name, + ] + ); + if (!$result) { + $ok = false; + } + } + return $ok; + } } From 72432ee5611ab3bd9fb66b3e8dfbd9d1faade063 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:31:59 +0200 Subject: [PATCH 2/9] adapt changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd7603e..83dc01d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [UNRELEASED] +## [unreleased] ### Fixed From 407e6388de73a5e54557b6aee9dbd65a4c7786ee Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:39:16 +0200 Subject: [PATCH 3/9] fix --- hook.php | 1 - inc/profile.class.php | 22 ++++------------------ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/hook.php b/hook.php index 4eae3c7..3b722c7 100644 --- a/hook.php +++ b/hook.php @@ -98,7 +98,6 @@ function plugin_uninstall_uninstall() require_once($dir . "/inc/config.class.php"); PluginUninstallProfile::uninstall(); - PluginUninstallProfile::deleteProfileRights([PluginUninstallProfile::RIGHT_REPLACE]); PluginUninstallModel::uninstall(); PluginUninstallPreference::uninstall(); PluginUninstallConfig::uninstall(); diff --git a/inc/profile.class.php b/inc/profile.class.php index c3b295e..6ddf1a2 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -304,25 +304,11 @@ public static function uninstall() global $DB; $DB->doQuery("DROP TABLE IF EXISTS `" . getTableForItemType(self::class) . "`"); - } - - public static function deleteProfileRights(array $rights) - { - global $DB, $GLPI_CACHE; - $GLPI_CACHE->set('all_possible_rights', []); - $ok = true; - foreach ($rights as $name) { - $result = $DB->delete( - self::getTable(), - [ - 'name' => $name, - ] - ); - if (!$result) { - $ok = false; - } + foreach (self::getGeneralRights() as $right) { + ProfileRight::deleteProfileRights([$right['field']]); } - return $ok; } + + } From 0d82362da6f74374de99b6231811901f75d46201 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:43:28 +0200 Subject: [PATCH 4/9] fix --- inc/profile.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/profile.class.php b/inc/profile.class.php index 6ddf1a2..7e419e2 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -38,7 +38,7 @@ class PluginUninstallProfile extends Profile * * @return array rights matrix */ - public function getGeneralRights() + public static function getGeneralRights() { return [ [ @@ -71,7 +71,7 @@ public function showForm($ID, $options = []) $this->showFormHeader($options); } - $rights = $this->getGeneralRights(); + $rights = self::getGeneralRights(); $profile->displayRightsChoiceMatrix($rights, ['canedit' => $canedit, 'default_class' => 'tab_bg_2', ]); From 6772599d651afa970c23221815acacdacab89798 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:51:43 +0200 Subject: [PATCH 5/9] fix --- inc/profile.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inc/profile.class.php b/inc/profile.class.php index 7e419e2..7c43839 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -305,9 +305,11 @@ public static function uninstall() $DB->doQuery("DROP TABLE IF EXISTS `" . getTableForItemType(self::class) . "`"); + foreach (self::getGeneralRights() as $right) { ProfileRight::deleteProfileRights([$right['field']]); } + ProfileRight::deleteProfileRights(['plugin_uninstall_replace']); } From e56f9072e8984bbdec7ee02e79b3e72f3882d591 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:52:47 +0200 Subject: [PATCH 6/9] fix CS --- inc/profile.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/inc/profile.class.php b/inc/profile.class.php index 7c43839..ca2a83a 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -305,7 +305,6 @@ public static function uninstall() $DB->doQuery("DROP TABLE IF EXISTS `" . getTableForItemType(self::class) . "`"); - foreach (self::getGeneralRights() as $right) { ProfileRight::deleteProfileRights([$right['field']]); } From a18544c228dd1ef70ddb7604d7af97097c98cb85 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:53:08 +0200 Subject: [PATCH 7/9] fix CS --- inc/profile.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/inc/profile.class.php b/inc/profile.class.php index ca2a83a..c6729b5 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -310,6 +310,4 @@ public static function uninstall() } ProfileRight::deleteProfileRights(['plugin_uninstall_replace']); } - - } From 6f6543125e72b635731f085ee739be9d9265ffe7 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:53:23 +0200 Subject: [PATCH 8/9] fix CS --- hook.php | 1 - 1 file changed, 1 deletion(-) diff --git a/hook.php b/hook.php index 3b722c7..af4e28f 100644 --- a/hook.php +++ b/hook.php @@ -101,6 +101,5 @@ function plugin_uninstall_uninstall() PluginUninstallModel::uninstall(); PluginUninstallPreference::uninstall(); PluginUninstallConfig::uninstall(); - return true; } From 2d66ca4e65cac8ca4e958152d184bfc86c1790b8 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:02:25 +0200 Subject: [PATCH 9/9] fix rector --- inc/profile.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/profile.class.php b/inc/profile.class.php index c6729b5..c2c2a90 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -308,6 +308,7 @@ public static function uninstall() foreach (self::getGeneralRights() as $right) { ProfileRight::deleteProfileRights([$right['field']]); } + ProfileRight::deleteProfileRights(['plugin_uninstall_replace']); } }