Upgrading Umbraco from 3 to 4 – Not all smooth sailing

comments

If you have ever had to setup or manage an Umbraco installation you will know both the pleasure and the occasional pain that it can bring. Umbraco is part of the growing list of “oober cool” up and coming Dot Net CMS that are getting attention in the “get it up quick” world of marketing driven sites in the market place (Ford Australia for example). I recently had to upgrade a clients installation from 3.0.5 to 4.0.2.1 and the story that follows will hopefully help someone in a similar position so that they can revel in the same relief that I do currently.

Follow the installation guide (but don’t depend on it)

I won’t go through all the steps involved in the upgrade process as the Umbraco Codeplex site (click on upgrade guide) and quite a few blog entries detail this – if you are experiencing issues simply upgrading and haven’t looked on Google then this guide should not be your first stop. What appeared to happen to my installation was not covered in any of the usual stuff and the battle that ensued is what i am going to discuss.

I followed the install guide and it successfully updated my database (partially, but we’ll get to that), my templates to the new master page format and all the files involved to run the new version. The list that follows is my list of issues and each solution.

Issue 1: Unable to login to the admin

This is an issue that has been flagged very clearly in the install guide and i was aware of but i thought i would mention it as quite a few people repeatedly discuss this in Umbraco’s Forums.

Umbraco 4’s Membership provider now hashes its passwords for better security, so after upgrading, your old passwords (unhashed) will not match a hashed copy of your entered password.

There is a really simple fix: turn clear passwords back on.

Below is a copy of a before and after of my membership provider part of my web.config that does just this:

Before:

<add name="UmbracoMembershipProvider" 
    type="umbraco.providers.members.UmbracoMembershipProvider" 
    enablePasswordRetrieval="false" 
    enablePasswordReset="false" 
    requiresQuestionAndAnswer="false" 
    defaultMemberTypeAlias="Another Type" 
    passwordFormat="Hashed" />

After

<add name="UmbracoMembershipProvider" 
    type="umbraco.providers.members.UmbracoMembershipProvider" 
    enablePasswordRetrieval="false" 
    enablePasswordReset="false" 
    requiresQuestionAndAnswer="false" 
    defaultMemberTypeAlias="Another Type" 
    passwordFormat="Clear" />

After making the above change you should be ready to rock and roll. Point your browser at the Umbraco site (usually /umbraco/) and you should be all good.

Issue 2: After logging in all content does not show

UmbracoEmptyContent

The second issue was a perfect example of the feeling “so-close-yet-so-far”, as my installation’s admin area was now functional and i was logged in. Everything looked pretty and Umbraco-4-ish and yet all my client’s content was missing. I was starting to think that the upgrade had failed, my database backup from the clients server was corrupt or any number of things. One of the strange things was that if i right clicked on the top node and clicked on Sort all my content was available for sorting.

After half an hours searching on the big G i found someone in the Umbraco forums had mentioned that they had fixed this issue by simply Republishing the whole site. I was really excited to have found a solution.

Until it did nothing…. :(
(I’d still try this incase it works for your installation)

Starting to feel like i was at the beginning of a long journey i started digging around in the Umbraco database to both see if the content was missing, as well as try and figure out what could be done to rectify the situation.

I soon found that there were no records setting up permissions from my account to view the nodes that the content was stored in. This was going to need some rectification to the database by hand.

Luckily for me someone had shared this issue - David Conlisk from Web garden (If your living in Umbraco world you should really check out his site) and had received help from an Umbraco solution provider already: Connect Digital.

David has nicely allowed me to include the SQL below:

/* Add ActionBrowse as a default permission to all 
user types that have ActionUpdate */ UPDATE umbracoUserType SET userTypeDefaultPermissions =
userTypeDefaultPermissions + 'F' WHERE
CHARINDEX('A',userTypeDefaultPermissions,0) >= 1 AND
CHARINDEX('F',userTypeDefaultPermissions,0) < 1; /* Add ActionToPublish to all users types that have the alias 'writer' */ UPDATE umbracoUserType SET userTypeDefaultPermissions = userTypeDefaultPermissions + 'H' WHERE userTypeAlias = 'writer' AND CHARINDEX('F',userTypeDefaultPermissions,0) < 1 ; /* Add ActionBrowse to all user permissions for nodes that have the ActionUpdate permission */ IF NOT EXISTS (SELECT permission FROM umbracoUser2NodePermission WHERE permission='F') INSERT INTO umbracoUser2NodePermission (userID, nodeId, permission) SELECT userID, nodeId, 'F' FROM umbracoUser2NodePermission WHERE permission='A' ; /* Add ActionToPublish permissions to all nodes for users that are of type 'writer' */ IF NOT EXISTS (SELECT permission FROM umbracoUser2NodePermission WHERE permission='H') INSERT INTO umbracoUser2NodePermission (userID, nodeId, permission) SELECT DISTINCT userID, nodeId, 'H' FROM umbracoUser2NodePermission WHERE userId IN (SELECT umbracoUser.id FROM umbracoUserType INNER JOIN umbracoUser ON umbracoUserType.id = umbracoUser.userType WHERE (umbracoUserType.userTypeAlias = 'writer')) ; /* Add the contentRecycleBin tree type */ IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE treeAlias='contentRecycleBin') INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) VALUES (0, 0, 0, 'content', 'contentRecycleBin', 'RecycleBin', 'folder.gif', 'folder_o.gif', 'umbraco', 'cms.presentation.Trees.ContentRecycleBin') ; /* Add the UserType tree type */ IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE treeAlias='userTypes') INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) VALUES (0, 1, 1, 'users', 'userTypes', 'User Types', 'folder.gif', 'folder_o.gif', 'umbraco', 'cms.presentation.Trees.UserTypes') ; /* Add the User Permission tree type */ IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE treeAlias='userPermissions') INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) VALUES (0, 1, 2, 'users', 'userPermissions', 'User Permissions', 'folder.gif', 'folder_o.gif', 'umbraco', 'cms.presentation.Trees.UserPermissions') ;

After running the above SQL against my database, republishing the entire site through the admin and then restarting the app to clear Umbraco’s cache i still had no content!

NOTE: After running the upgrade a second time once getting everything working i now know that you still have to run the above regardless.

I needed to look elsewhere. This is when i came across a part of the web.config (by pure fluke) that looks like below:

<add key="umbracoHideTopLevelNodeFromPath" value="true" />

After setting this to false and restarting the site i was looking at all the content nodes.

Woohoo!

Issue 3: Media management not functioning and badly named

Now that i had content working i was over the moon. Thought i was home and hosed.

I was wrong.

All my media was showing up fine but i wanted to be a good developer and test it. After quickly testing that i could upload a new image and delete it to simply make sure that, what i thought, may be any potential file permission issues i hit another stop on our journey.

It appeared that any action on the sites media would cause a Dot Net error. It was then that i realised that the whole section was called Medier, and after reviewing the stack track realised that it was trying to talk to a folder called medier as well.

How odd…

A quick search found that someone else had also had an issue with this on an older version upgrade – maybe i shared the same issue. What i didn’t know is that Medier is how they spell it in Denmark.

They posted a bit of SQL that would change the node information to list it properly as Media. I ran this script (listed on the above post) however it was not enough as it did not set the treeAlias (folder name) property as well.

A simple modification to this script is shown below that will reset both properties:

 

update umbracoAppTree 
set treeTitle='Media', treeAlias='media'
where treeTitle='Medier';

 

Another quick restart of the Umbraco cache and i was away… :) Media worked.

Issue 4: Adding package support now that you’ve upgraded

My new Umbraco 4 installation was humming along and i was a happy developer. The only other thing that was a quick tweak was changing the data type RichTextBox to use the new version of TinyMCE installed with Umbraco 4. This was easy as a nice little JavaScript alert informed me what i should do to fix it (how cool is that – great work guys).

It was then that the next stage of my clients upgrade brought about the attention of a missing feature in my new Umbraco 4 installation. I was attempting to install a plug-in for Umbraco called Umbraco Blog when i quickly realised: I was missing the new glorious packaging system that everyone over at Umbraco is raving about.

Here we go again!…

So obviously i was missing part of the upgrade. Why? I had started to think that some of the issues i was having was because i had not upgraded to mid-point version that had included a lot of other things included, and that these things weren’t added to the upgrade to 4.0.

I then i remembered something from David Conlisk’s post that mentioned looking in the total.sql for Umbraco over at CodePlex – this can be accessed here.

After doing a quick find in my browswer i came across two very interesting lines shown below.

/* 3.1 SQL changes */
INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], 
[treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], 
[treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) 
VALUES (N'developer', N'packager', 0, 1, 3, N'Packages', N'folder.gif', 
N'folder_o.gif', N'umbraco', N'loadPackager');

INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], 
[treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], 
[treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) 
VALUES (N'developer', N'packagerPackages', 0, 0, 1, N'Packager Packages', 
N'folder.gif', N'folder_o.gif', N'umbraco', N'loadPackages');

After running these lines against my Umbraco DB I was done. It worked!

Happy days. Everything is now working and I live on to fight another day.