]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4923 Fix parent update where active rules from previous parent were not disabled
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 21 Jan 2014 10:56:40 +0000 (11:56 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 21 Jan 2014 10:56:50 +0000 (11:56 +0100)
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java

index 31541922c9889ada5ad032beb127336ae2c05bad..96d55cf235c704d6e7aa2c45890c4c9af342ac26 100644 (file)
@@ -178,12 +178,13 @@ public class QProfileOperations implements ServerComponent {
       if (isCycle(profile, parentProfile, session)) {
         throw new BadRequestException("Please do not select a child profile as parent.");
       }
-      String parentName = parentProfile != null ? parentProfile.getName() : null;
-      profile.setParent(parentName);
+      String newParentName = parentProfile != null ? parentProfile.getName() : null;
+      // Modification of inheritance has to be done before setting new parent name in order to be able to disable rules from old parent
+      ProfilesManager.RuleInheritanceActions actions = profilesManager.profileParentChanged(profile.getId(), newParentName, userSession.name());
+      profile.setParent(newParentName);
       dao.update(profile, session);
       session.commit();
 
-      ProfilesManager.RuleInheritanceActions actions = profilesManager.profileParentChanged(profile.getId(), parentName, userSession.name());
       ruleRegistry.deleteActiveRules(actions.idsToDelete());
       ruleRegistry.bulkIndexActiveRuleIds(actions.idsToIndex(), session);
     } finally {