Feature Install having settings, delete, install again problem

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
3/9/2010 6:47:26 AM
Gravatar
Total Posts 15
Growing old is inevitable, growing up is optional :)

Feature Install having settings, delete, install again problem

Hi,

I'm developing custom module/feature under windowsXP, MSSQL, mojo version 2.3.3.6

and I have created:
- custom project in solution,
- module, resource file
- set xcopy to mojo/bin and resources ...
- created under Setup/applications/myapp/0000_myapp.config and defined mySetting there
- xcopy also for that

login as admin in mojo, go to /Setup/Default.aspx, all goes well
myapp is in feature list, and mySetting is in its settings list
Look in db there is in mp_ModuleDefinitions under ID = 42 --> ok
Look in db in mp_ModuleDefinitionSettings it's there under 254 (moduleDefId = 42)

/Admin/ModuleAdmin.aspx  --> myapp- edit and then delete
no more ID 42 in mp_ModuleDefinitions BUT mySetting is still in mp_ModuleDefinitionSettings having FK 42 ?!?
I don't know how this can happen since it is FK? Maybe in db upgrade from previous versions something was wrong.

(UPDATE: I have just tried new mojo portal 2.3.3.6 from empty DB and moduleDefId is NOT FK)

I do again /Setup/Default.aspx, all goes well, new moduleDefId is now 43
BUT since it probably founds feature guid it does not install mySetting (since it is there under moduleDefID = 42 but same guid) and now I don't have mySetting under myApp module.

If I manually delete "hanging" rows from mp_ModuleDefinitionSettings and start again Setup/Default.aspx
all is created well again and works ok.

Generally problem is in Feature Delete, and if somebody like me is in try/delete phase of feature installation through config files :)

UPDATE: I have just noticed that also is not deleted in mp_SiteModuleDefinitions resulting that in next install it does not insert it there with new id and stored procedure "mp_ModuleDefinitions_SelectUserModules" does not retrieve it in feature list (and user cannot see it if wants to add on page)

Cheers
Goran
 

3/9/2010 9:57:10 AM
Gravatar
Total Posts 18439

Re: Feature Install having settings, delete, install again problem

Hi Goran,

It is challenging to come up with a comprehensive uninstall system. Due to the fact that custom features may have their own tables with moduleid/moduleguid and there is no way that mojoPortal can know about feature specific tables, part of the deletion strategy must be implemented by the feature developer. 

The steps I recommend are

  1. Delete each instance of your feature from the module settings page for an instance if you delete it it will delete the instance from all pages containing the instance and then it will delete the module instance. But to delete data from feature tables you must implement a ContentDeleteHandler. I don't currently have documentation about this other than the source code for included features which all support it if they have their own tables. The handlers are registered from config files under /Setup/ProviderConfig/contentdeletehandlers. you have to implement your own ContentDeleteHandler inheriting from mojoPortal.Business.WebHelpers.ContentDeleteHandlerProvider which simply defines a void where the moduleid and moduleguid will be passed so your code can do what it needs to delete related content. You must do this in each site where the feature is used.
  2. Now that all instances are deleted from the UI, you can also delete feature settings then delete the feature itself from Advanced Tools > Feature Installation
  3. In addition to contentdeletehandlers, included features also implement SitePreDeleteHandlers that delete feature content based on siteid so the content can be deleted before the site is deleted.

Now I do consider it a bug that we are not deleting the it from mp_SiteModuleDefinitions. I will fix that. I thought we already had that in place. In a multi site installation you can remove it from that table for child sites because there is a UI element in Site Settings for installing or removing features from a child site.

Going forward I think we could improve the process by implementing a provider model to plugin featuredeletehandlers. This would allow deleting a feature without manually deleting instances but it would depend on the feature developer to remove all instance content in all sites in this event. 

Deleting features is even more challenging the more complex they are. Consider the BlogContentDeleteHandler, if you delete an instance of a blog then it must delete the blog content but also the friendly urls and it must clear content that was previously indexed into the search index.

Best,

Joe

3/10/2010 5:55:02 AM
Gravatar
Total Posts 15
Growing old is inevitable, growing up is optional :)

Re: Feature Install having settings, delete, install again problem

Hi Joe,

Thank you for your answer.

1. all clear and understandable. If I want to uninstall my custom feature that has custom tables in db I need to implement DeleteHandler. I'll find examples in code. I think there should be no problem (do you reccomend any specific not complicated feature as example? :) )

2. if I understand procedure is going to /Admin/ModuleAdmin.aspx (Feature installation/configuration)
- clicking on Settings (showing list of feature custom settings)
- clicking on edit for each one and delete it
- after deleting all custom settings I can click on edit feature and delete it
(this works ok)

3. clear

I would like to add idea if I may, at 2. it is slow deleting settings first (especially if there are more then 10-15) and then feature (module) definition.
For me as a developer it would be more convinient if I just delete feature (module) definition and automatic sequence deletes from
- mp_ModuleDefinitionSettings (if there are any) // maybe this is not possible because of something I don't see it now?
- mp_SiteModuleDefinitions   (you said this should (will) be implemented (fixed) )
- mp_ModuleDefinitions (as it deletes now)

Because if I make mistake and delete feature, and install it again I cannot access old installed settings even if I want to delete them one by one, and I cannot have them as settings for my again installed feature. From this point only manual delete in table can fix this.

All other deletes are and should be handled in user custom delete handler.

This is rare situation. As developer I create feature then one more, then I change my mind about naming. So I uninstall and install feature ...
Later in development this should not happen.

Goran

3/10/2010 6:32:20 AM
Gravatar
Total Posts 18439

Re: Feature Install having settings, delete, install again problem

Hi Goran,

If you change your mind about naming, you should be able to just edit the feature definition, you can change the controlsrc path or feature name at any time, visit setup and it will update those changes. If all else fails you could always use a new featureguid when re-installing. Once you ship a feature to customers the feature guid should never change, but you can get away with changing it if you have not released the feature to others.

Best,

Joe

3/10/2010 6:43:51 AM
Gravatar
Total Posts 15
Growing old is inevitable, growing up is optional :)

Re: Feature Install having settings, delete, install again problem

yup, changing guid saves situation if needed :)

thanx
G.

You must sign in to post in the forums. This thread is closed to new posts.