Copied to clipboard

Flag this post as spam?

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


  • Richard Boelen 61 posts 153 karma points
    Jun 10, 2011 @ 09:56
    Richard Boelen
    0

    Bug in the root content node

     

     

    Hi,

    after installing your package I got a bug on the root content node saying:

    Object reference not set to an instance of an object.


    After uninstalling, I got my root node back, but it leaves some uBlogsy tabs on the root node.
    [NullReferenceException: Object reference not set to an instance of an object.]
       uBlogsy.Web.usercontrols.uBlogsy.dashboard.Admin.OnLoad(EventArgs e) +366
    

    Also uninstalling is somewhat troublesome, because you should first delete de child document types before deleting the master document type.

     

    Cheers,

    Richard

     

     

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jun 10, 2011 @ 13:50
    Anthony Dang
    0

    Hi Richard

    That bug is really strange. I cannot replicate it.

    I assume you're on Umbraco 4.7

    Do you have any other starter kits installed?

    Or any other tabs before installing the package?

    Are there any nodes published before you installed the package?

     

  • Richard Boelen 61 posts 153 karma points
    Jun 10, 2011 @ 15:24
    Richard Boelen
    0

    Hi,

    I am on 4.7.0 , only packages installed are: ImageGen, FamFamFam icons, Twitter for Umbraco

    I have no starter kit, it's a fresh install of umbraco and buildup from the ground.

    There was already content made and published. All running local on my dev machine btw.

    Not sure what's happening and I am not able to debug it without source or pdb's

    In Dashboard.config I have multiple tabs for BLog Comments & RSS Import tool, that might be the problem...

  • Richard Boelen 61 posts 153 karma points
    Jun 10, 2011 @ 15:26
    Richard Boelen
    0

    When I uncomment Blog Comments, than the tabs work again. RSS Import tab seems to work also.

  • Stuart Burrows 61 posts 110 karma points
    Jun 10, 2011 @ 16:36
    Stuart Burrows
    0

    I've been having this problem as well since the RSS import tool. I'd not raised it because I figured it was my sandpit environment but I've just set up a lovely fresh new site and the same issue occurs.

    As for uninstalling I understood this to be a umbraco issue, rather than an issue with this package.

    @Richard where is Blog Comments commented?

  • Stuart Burrows 61 posts 110 karma points
    Jun 10, 2011 @ 16:39
    Stuart Burrows
    0

    Ah nm, seems to be this in dashboard.config:

    <tab caption="Blog Comments">
         
    <control addPanel="true">/usercontrols/uBlogsy/dashboard/Admin.ascx</control>
       
    </tab>

    Commenting this out allows the to load the content root node BUT I get an error when trying to use the RSS import tool (not previsouly tested). I am using v1.31

  • Richard Boelen 61 posts 153 karma points
    Jun 10, 2011 @ 17:13
    Richard Boelen
    0

    Yes , same here when using RSS import..

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jun 10, 2011 @ 18:34
    Anthony Dang
    0

    This is really strange.

    I've installed those 3 packages that you have Richard but cannot replicate the issue.

    I might need some help debugging this. Below is what happens when the comments are displayed:

     

            protected void LoadComments()
    {
    Comments = new List<Document>();

    // get id root of blog
    Document blogFolder = DocumentHelper.GetDocumentByAlias("uBlogsyFolderBlog");
    if (blogFolder == null)
    {
    // hmm...the blog page was not there.
    return;
    }

    // iterate through year folders of the blog folder
    foreach (Document yearFolder in blogFolder.Children)
    {
    // iterate through year folders of the blog folder
    foreach (Document childDoc in yearFolder.Children)
    {
    if (childDoc.ContentType.Alias == "uBlogsyFolderMonth")
    {
    // this year has month folders
    foreach (Document post in childDoc.Children)
    {
    GetUnpublishedComments(post);
    }
    }
    else
    {
    // this year has posts - but possibly months too
    GetUnpublishedComments(childDoc);
    }
    }
    }
    }

     

     

            /// This is a recursive method to get a document by it's alias.
            public static Document GetDocumentByAlias(string alias)
            {
                IEnumerable docs = Document.GetRootDocuments();
    
                foreach (Document d in docs)
                {
                    var res = GetDocumentByAlias(d, alias);
                    if (res.ContentType.Alias == alias)
                    {
                        return res;
                    }
                }
    
                return null;
            }

    private static Document GetDocumentByAlias(Document d, string alias)
    {
    if (d.ContentType.Alias == alias)
    {
    return d;
    }

    // check direct children fist
    foreach (var c in d.Children)
    {
    if (c.ContentType.Alias == alias)
    {
    return c;
    }
    }

    // now try next level
    foreach (var c in d.Children)
    {
    return GetDocumentByAlias(c, alias);
    }
    return null; // not found but this should not be the case
    }



            /// Gets unpublished comments from the post
            private List GetUnpublishedComments(Document doc)
            {
                // get the comments folder
                Document commentsFolder = doc.Children.Where(x => x.ContentType.Alias == "uBlogsyFolderComment").FirstOrDefault();
    
                if (commentsFolder != null)
                {
                    // get all comments from comments folder which are not published
                    Comments.AddRange(commentsFolder.Children.Where(x => !x.Published));
                }
    
                return Comments;
            }
    
  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jun 10, 2011 @ 19:16
    Anthony Dang
    0

    Ok I think I figured it out.Or at least figured out something...

    I was able to get it to crash after installing a starter kit. I hope this is the same issue. Basically it is to do with multiple nodes at the root of the content tree and not checking for null.

    if (res.ContentType.Alias == alias)

    should have been

    if (res != null && res.ContentType.Alias == alias)
     public static Document GetDocumentByAlias(string alias)
            {
                IEnumerable docs = Document.GetRootDocuments();
    
                foreach (Document d in docs)
                {
                    var res = GetDocumentByAlias(d, alias);
                    if (res != null && res.ContentType.Alias == alias)
                    {
                        return res;
                    }
                }
    
                return null;
            }
    

     

    I'll put up a release as soon as I'm sober tomorrow.

Please Sign in or register to post replies

Write your reply to:

Draft