Copied to clipboard

Flag this post as spam?

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


  • Richard Barg 358 posts 532 karma points
    Jun 27, 2012 @ 20:05
    Richard Barg
    0

    Tree Nodes Will Not Sort Past Upper 25-30 Nodes

    Umbraco Version - 4.7.1

    Windows Server 2008 – 8gb memory – 4 Zeon 2.27Ghz processors service pack 1 – 64 bit OS

    IIS version 7.5.7600.16385

    SQL Server 2008 R2

    Stacktrace - N/A

     

    As can be seen below, we have a very large tree structure - over 55 websites.  When attempting to sort the top nodes of the tree, rearranging below the area highlighted in yellow fails.  The sort runs and returns a dialog box that the sort was completed, but the items are still in their original place. Within the area in yellow the sort runs fine.

     

     

     

  • skiltz 501 posts 701 karma points
    Jun 27, 2012 @ 22:14
    skiltz
    0

    Have you checked the Umbraco Log table in the database to see if there is any errors?

  • Simon steed 376 posts 688 karma points
    Sep 14, 2012 @ 23:52
    Simon steed
    0

    I've a possible fix for this, I can send you the revised cms.dll (4.7.1.1 though) for you to try or let you know the code to modify so you can test yourself?

  • Richard Barg 358 posts 532 karma points
    Sep 15, 2012 @ 02:26
    Richard Barg
    0

    Sure, we're on 4.7.1 so the later course seems best.  Thanks Simon.

  • Simon steed 376 posts 688 karma points
    Sep 16, 2012 @ 09:20
    Simon steed
    0

    Well I ran into a problem, basically we were running 4.7.1.1 so I grabbed the 4.7.1.1 source and rebuilt that with the new changes and it completely broke the XSLT engine.

    Wierd as I thought that should not happen, the code I changed should not affect that so I grabbed the clean source again and rebuilt then copied the cms.dll over to my bin folder, same thing again!

    So it seems that the cms.dll in the 4.7.1.1 folder is not the same one as is compiled with the 4.7.1.1. source! In the end I upgraded our site to 4.9.0 (which was laborious) and will add the changes to that codebase

    In a nutshell, I don't have a dll that I can send you as it will 100% break rendering of xslt macros - do you have visual studio so you can try it yourself as I can tell you the fix I added (only a try..catch block) or you can look at this as the real source of the problem.

    The reason the sort was not working for us was that there was an empty string being returned for one of the SQL Statements being run to import the xml in cms.dll.

    select xml from cmsContentXml where nodeID = 1390

    Run this against your db and change the nodeid to those that are not sorting properly, i'll bet they are returning nothing. (i've not tried this next bit yet) but try republishing the node that fails then run that sql again, in theory the XML should now be present and that node should sort.

    My fix resolved around the fact that when the method calling this sql threw an exception, although the global exception handler was catching it, the code that used the resultset was never run hence the xml would never be generated!

    This is the old method:

    public void refreshXmlSortOrder()

            {

                if (Published)

                {

                    if (_xml == null)

                        // Load xml from db if _xml hasn't been loaded yet

                        _xml = importXml();

                    // Generate xml if xml still null (then it hasn't been initialized before)

                    if (_xml == null)

                    {

                        XmlGenerate(new XmlDocument());

                        _xml = importXml();

                    }

                    else

                    {

                        // Update the sort order attr

                        _xml.Attributes.GetNamedItem("sortOrder").Value = sortOrder.ToString();

                        saveXml(_xml);

                    }

                }

            }

    and this is the new one (document.cs in the umbraco.cms/businesslogic/web/document.cs file)

            public void refreshXmlSortOrder()

            {

                if (Published)

                {

                    if (_xml == null)

                        // Load xml from db if _xml hasn't been loaded yet

                        try

                        {

                            _xml = importXml();

                        }

                        catch (Exception ex)

                        {

                            Log.Add(LogTypes.Error, 0, ex.ToString());

                        }

                    // Generate xml if xml still null (then it hasn't been initialized before)

                    if (_xml == null)

                    {

                        XmlGenerate(new XmlDocument());

                        _xml = importXml();

                    }

                    else

                    {

                        // Update the sort order attr

                        _xml.Attributes.GetNamedItem("sortOrder").Value = sortOrder.ToString();

                        saveXml(_xml);

                    }

                }

            }

    As you will see, i'm handling the error thrown back from importXML(); which then allows the next lines to generate the xml fresh, before when the call to importXML threw an exception, it resulted in the rest of the refreshXmlSortOrder method bombing out

    I'll point Sebastian at this post as he may be able to roll this out as a better fix for the next release!

    Hope this helps!

    Si

Please Sign in or register to post replies

Write your reply to:

Draft