Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rick Noelle 10 posts 43 karma points
    Sep 22, 2010 @ 19:30
    Rick Noelle
    1

    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:

    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();
            }
    
        }
    }
    

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 22, 2010 @ 20:07
    Dirk De Grave
    1

    Rick,

     

    Could you report this on Codeplex?

     

    TIA,

    /Dirk

  • Rick Noelle 10 posts 43 karma points
    Sep 22, 2010 @ 21:04
    Rick Noelle
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft