Copied to clipboard

Flag this post as spam?

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


  • Alan Howlett 19 posts 54 karma points
    Dec 12, 2013 @ 12:42
    Alan Howlett
    0

    IndexOutofRangeException: uniqueId

    Hi,

    I currently have a customer with an Umbraco 4.7.1.1 site and they keep getting the following error randomly occurring when they are publishing or unpublishing nodes:

    uniqueID

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.IndexOutOfRangeException: uniqueID

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

     

    [IndexOutOfRangeException: uniqueID]

       System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +5057482

       System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +67

       umbraco.DataLayer.RecordsReaderAdapter`1.GetOrdinal(String fieldName) +23

       umbraco.DataLayer.RecordsReaderAdapter`1.IsNull(String fieldName) +26

       umbraco.cms.businesslogic.CMSNode.PopulateCMSNodeFromReader(IRecordsReader dr) +22

       umbraco.cms.businesslogic.CMSNode.setupNode() +153

       umbraco.cms.businesslogic.web.Document.setupNode() +40

       umbraco.cms.businesslogic.CMSNode..ctor(Int32 Id) +36

       umbraco.cms.presentation.editContent.updateLinks() +372

       umbraco.cms.presentation.editContent.Publish(Object sender, EventArgs e) +674

       System.EventHandler.Invoke(Object sender, EventArgs e) +0

      umbraco.controls.ContentControl.savePublish(Object Sender, ImageClickEventArgs e) +45

       System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +115

       System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +120

       System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10

       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13

       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36

       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

    Looking at the source code, the method causing the problems is as follows (offending lines highlighted in bold):

            protected void PopulateCMSNodeFromReader(IRecordsReader dr)
            {
                // testing purposes only > original umbraco data hasn't any unique values ;)
                // And we need to have a parent in order to create a new node ..
                // Should automatically add an unique value if no exists (or throw a decent exception)
                if (dr.IsNull("uniqueID")) _uniqueID = Guid.NewGuid();
                else _uniqueID = dr.GetGuid("uniqueID");


                _nodeObjectType = dr.GetGuid("nodeObjectType");
                _level = dr.GetShort("level");
                _path = dr.GetString("path");
                _parentid = dr.GetInt("parentId");
                _text = dr.GetString("text");
                _sortOrder = dr.GetInt("sortOrder");
                _userId = dr.GetInt("nodeUser");
                _createDate = dr.GetDateTime("createDate");
                _isTrashed = dr.GetBoolean("trashed");
            }

    For some reason the 'uniqueId' field doesn't exist against the nodes at, what appears to be, random intervals (i.e. it can happen on specific nodes at times and the not others)

    As a rudimentary fix, I suggest having the following code:

                // testing purposes only > original umbraco data hasn't any unique values ;)
                // And we need to have a parent in order to create a new node ..
                // Should automatically add an unique value if no exists (or throw a decent exception)
                if (!dr.ContainsField("uniqueID") || dr.IsNull("uniqueID")) _uniqueID = Guid.NewGuid();
                else _uniqueID = dr.GetGuid("uniqueID");

    Ideally I'd like to know the unerlying cause of this as my customer is planning to upgrade their version of Umbraco in the next few months and I notice that the same piece of code is still in place on the latest version (unchanged) so didn't want to have to keep re-adding the rudimetary fix above on each upgrade.

     

Please Sign in or register to post replies

Write your reply to:

Draft