Source:
public void delete(final Field field, final User user) throws DotDataException, DotSecurityException { final ContentTypeAPI contentTypeAPI = APILocator.getContentTypeAPI(user); final ContentType type = contentTypeAPI.find(field.contentTypeId()); permissionAPI.checkPermission(type, PermissionLevel.EDIT_PERMISSIONS, user); Field oldField = fieldFactory.byId(field.id()); if(oldField.fixed() || oldField.readOnly()){ throw new DotDataException("You cannot delete a fixed or read only field"); } Structure structure = new StructureTransformer(type).asStructure(); com.dotmarketing.portlets.structure.model.Field legacyField = new LegacyFieldTransformer(field).asOldField(); if (!(field instanceof CategoryField) && !(field instanceof ConstantField) && !(field instanceof HiddenField) && !(field instanceof LineDividerField) && !(field instanceof TabDividerField) && !(field instanceof RelationshipsTabField) && !(field instanceof RelationshipField) && !(field instanceof PermissionTabField) && !(field instanceof HostFolderField) && structure != null ) { this.contentletAPI.cleanField(structure, legacyField, this.userAPI.getSystemUser(), false); } fieldFactory.moveSortOrderBackward(type.id(), oldField.sortOrder()); fieldFactory.delete(field); ActivityLogger.logInfo(ActivityLogger.class, "Delete Field Action", String.format("User %s/%s eleted field %s from %s Content Type.", user.getUserId(), user.getFirstName(), field.name(), structure.getName())); contentTypeAPI.updateModDate(type); CacheLocator.getContentTypeCache().remove(structure); if (field instanceof HostFolderField) { try { this.contentletAPI.cleanHostField(structure, this.userAPI.getSystemUser(), false); } catch(DotMappingException e) this.permissionAPI.resetChildrenPermissionReferences(structure); } if (field instanceof RelationshipField) { removeRelationshipLink(field, type); } if(field.indexed()){ contentletAPI.reindex(structure); } new ContentletLoader().invalidate(structure); HibernateUtil.addCommitListener(()-> { localSystemEventsAPI.notify(new FieldDeletedEvent(field.variable())); }); }

Target:
public void delete(final Field field, final User user) throws DotDataException, DotSecurityException { final ContentTypeAPI contentTypeAPI = APILocator.getContentTypeAPI(user); final ContentType type = contentTypeAPI.find(field.contentTypeId()); permissionAPI.checkPermission(type, PermissionLevel.EDIT_PERMISSIONS, user); Field oldField = fieldFactory.byId(field.id()); if(oldField.fixed() || oldField.readOnly()){ throw new DotDataException("You cannot delete a fixed or read only field"); } final Structure structure = new StructureTransformer(type).asStructure(); com.dotmarketing.portlets.structure.model.Field legacyField = new LegacyFieldTransformer(field).asOldField(); if (!(field instanceof CategoryField) && !(field instanceof ConstantField) && !(field instanceof HiddenField) && !(field instanceof LineDividerField) && !(field instanceof TabDividerField) && !(field instanceof RelationshipsTabField) && !(field instanceof RelationshipField) && !(field instanceof PermissionTabField) && !(field instanceof HostFolderField) && structure != null ) { this.contentletAPI.cleanField(structure, legacyField, this.userAPI.getSystemUser(), false); } fieldFactory.moveSortOrderBackward(type.id(), oldField.sortOrder()); fieldFactory.delete(field); ActivityLogger.logInfo(ActivityLogger.class, "Delete Field Action", String.format("User %s/%s deleted field %s from %s Content Type.", user.getUserId(), user.getFirstName(), field.name(), structure.getName())); contentTypeAPI.updateModDate(type); CacheLocator.getContentTypeCache().remove(structure); if (field instanceof HostFolderField) { try { this.contentletAPI.cleanHostField(structure, this.userAPI.getSystemUser(), false); } catch(DotMappingException e) this.permissionAPI.resetChildrenPermissionReferences(structure); } if (field instanceof RelationshipField) { removeRelationshipLink(field, type); } if(field.indexed()){ contentletAPI.reindex(structure); } new ContentletLoader().invalidate(structure); HibernateUtil.addCommitListener(()-> { localSystemEventsAPI.notify(new FieldDeletedEvent(field.variable())); }); }