Package Installer Bug (with example package and code)
Umbraco Version: 4.5.2
ASP.NET version 4.0
Windows: Server 2008 R2
IIS: 7
Stacktrace: None
Description:
I believe I found a bug with the package install system. When I create a custom package action by implementing IPackageAction, my Execute and Undo methods are processed properly if I don't restart my web site, recycle the app pool, edit the web.config, etc. between package installation and uninstallation. If, however, I do any of those things between the time the package is installed and the time the package is uninstalled, the Undo method does *not* get called.
I have created a simple test package to demonstrate this behavior. It can be downloaded here:
This test package does one simple thing. At install time, it creates a table in the database called "RickPackageBugTest". When you uninstall the package, it drops the table. To demonstrate the expected and buggy behavior, install the package and confirm the table has been created in your database. Then immediately uninstall the package (without restarting the web site, app pool, etc.). You will see that the RickPackageBugTest table is gone (expected behavior). Now, install the package again and verify again that the database table RickPackageBugTest exists. Before uninstalling the package, restart your web server or recycle your app pool. You can also just add a blank line to your web.config and save it. Now, uninstall the package and note that the table does not get dropped (buggy behavior). There are also debug messages written to the database in the Execute and Undo methods that can be used to confirm the method calls.
Below is the source code of the package action:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using umbraco.interfaces;
using umbraco.BusinessLogic;
namespace RickPackageBugTest
{
public class RickPackageBugTest : IPackageAction
{
public string Alias()
{
return "RickPackageBugTest";
}
public bool Execute(string packageName, XmlNode xmlData)
{
Log.Add(LogTypes.Debug, -1, "Execute method of RickPackageBugTest being called.");
// Create a test table on install
Application.SqlHelper.ExecuteNonQuery("CREATE TABLE RickPackageBugTest (id int)");
return true;
}
public bool Undo(string packageName, XmlNode xmlData)
{
Log.Add(LogTypes.Debug, -1, "Undo method of RickPackageBugTest being called.");
// Drop table on uninstall
Application.SqlHelper.ExecuteNonQuery("DROP TABLE RickPackageBugTest");
return true;
}
public XmlNode SampleXml()
{
throw new NotImplementedException();
}
}
}
Package Installer Bug (with example package and code)
Umbraco Version: 4.5.2
ASP.NET version 4.0
Windows: Server 2008 R2
IIS: 7
Stacktrace: None
Description:
I believe I found a bug with the package install system. When I create a custom package action by implementing IPackageAction, my Execute and Undo methods are processed properly if I don't restart my web site, recycle the app pool, edit the web.config, etc. between package installation and uninstallation. If, however, I do any of those things between the time the package is installed and the time the package is uninstalled, the Undo method does *not* get called.
I have created a simple test package to demonstrate this behavior. It can be downloaded here:
http://dl.dropbox.com/u/528943/Rick_Test_Package_1.0.zip
The package has one custom action "RickPackageBugTest" that is triggered in package.xml using the following syntax:
<Action runat="install" undo="true" alias="RickPackageBugTest" />
This test package does one simple thing. At install time, it creates a table in the database called "RickPackageBugTest". When you uninstall the package, it drops the table. To demonstrate the expected and buggy behavior, install the package and confirm the table has been created in your database. Then immediately uninstall the package (without restarting the web site, app pool, etc.). You will see that the RickPackageBugTest table is gone (expected behavior). Now, install the package again and verify again that the database table RickPackageBugTest exists. Before uninstalling the package, restart your web server or recycle your app pool. You can also just add a blank line to your web.config and save it. Now, uninstall the package and note that the table does not get dropped (buggy behavior). There are also debug messages written to the database in the Execute and Undo methods that can be used to confirm the method calls.
Below is the source code of the package action:
Rick,
Could you report this on Codeplex?
TIA,
/Dirk
Hi Dirk,
Thanks for the reply. I have just now added it http://umbraco.codeplex.com/workitem/28945
I was glad to meet you at CodeGarden 2010 and hope to see you at CodeGarden 2011! :-)
Rick Noelle
Definition 6
is working on a reply...