Copied to clipboard

Flag this post as spam?

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


  • Fredrik Sewén 39 posts 106 karma points
    Nov 19, 2009 @ 10:43
    Fredrik Sewén
    0

    Error when moving a document from a protected area to a non-protected area

    Hi,

    I'm having a problem in the Umbraco backend. When moving a document that's in a protected area of my site, to a public area, the protection remains on the docuement.

    This is my setup:

    -Public
      -Node1
      -Node2
      -Node3 
    -Protected (Role based protection)
      -Node4
      -Node5
      -Node6

    Since all sub-nodes to the protected node inherits the access-rights, all nodes under the protected node are protected (and Umbraco tells you that with a red stop-sign). 

    If I move Node4 from the protected area to the public area, the protection should be removed as well. But in the Umbraco backend the red stop-sign is remains on that document. 

    If i right-click Node4 and tries to remove the protection (Public access) I get a server error stating:

    [NullReferenceException: Object reference not set to an instance of an object.]
    umbraco.cms.businesslogic.web.Access.IsProtectedByMembershipRole(Int32 documentId, String role) +94
    umbraco.presentation.umbraco.dialogs.protectPage.Page_Load(Object sender, EventArgs e) +1194
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
    System.Web.UI.Control.OnLoad(EventArgs e) +99
    umbraco.BasePages.BasePage.OnLoad(EventArgs e) +15
    System.Web.UI.Control.LoadRecursive() +50
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

    The same if I try to publish the site.

    The fix i found so far is to add protection to the public node (now parent to Node4) and remove the protection from there. But that feels like a very crude way to do it.

    Is this a cache problem? Where is the protection stored? The /data/access.xml only consists of the parent node, so it's have to be stored somewhere else.

    Version: 4.0.1.2
    .NET: 2.0
    Windows 2003, IIS 6

    Thanks,

    /Fredrik


  • Fredrik Sewén 39 posts 106 karma points
    Nov 20, 2009 @ 09:48
    Fredrik Sewén
    0

    I have an update to the above. It was  a cache issue (umbraco.config).

    After moving a document, I manually went in and removed the /data/umbraco.config from my file system ("Republish entire site" is not enough). Then, when the umbraco.config was recreated everything work as it should. 

    Is this an Umbraco BUG? Clearly it shouldn't be that you have to remove a file manually to remove the protection?

    Thanks,

    /Fredrik

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 20, 2009 @ 10:02
    Dirk De Grave
    0

    Hi Fredrik,

    Could you be so kind to log this as a work item on Codeplex as it sounds as a bug? Don't forget to include repro steps, and your environmental details such as umbraco version/os/...!

     

    TIA,

    /Dirk

  • Fredrik Sewén 39 posts 106 karma points
    Nov 20, 2009 @ 10:20
    Fredrik Sewén
    0

    @Dirk - I will file it in codeplex. Still doing some more research before that. Need to find a workaround.

    To more clearly understand the problem I created a custom function to move the documents. It seems that if you clear the cache before moving the documents, Everything works as expected.

            public bool MoveDocument(int documentId, int parentId)
            {
                bool hasMoved = false;
                Document doc = new Document(documentId);
                if (doc.Parent.Id != parentId)
                {
                    doc.Move(parentId);
    
                    doc.Publish(new User("Admin"));
    
                    //Need to clear the cache before updating the documentCache
                    umbraco.cms.businesslogic.cache.Cache.ClearAllCache();
                    umbraco.library.UpdateDocumentCache(documentId);
    
            //Don't know if this is needed, but just in case...
            Access.RemoveProtection(doc.Id);
    
                    hasMoved = true;
                }
                else
                {
                    hasMoved = false;
                }
                return hasMoved;
            }
    

    The only thing that I don't like with this solution is that in the Umbraco API documentation you can read "Use with care ;)" for the umbraco.cms.businesslogic.cache.Cache.ClearAllCache()-method.

    Can you just clear the cache that have to do with the documents? I need to know the key for that particula cache? Anyone knows?

    Thanks,

    /Fredrik

  • Fredrik Sewén 39 posts 106 karma points
    Nov 20, 2009 @ 10:49
    Fredrik Sewén
    0

    Ok, another update. 

    Seems like it's enough to just clear the application tree cache. I'm guessing that's where the access information lies? 

    I updated my above function with:

    umbraco.cms.businesslogic.cache.Cache.ClearCacheItem("ApplicationTreeCache");

    instead of the ClearAllCache-method.

    I'm guessing i'll use my custom method to move the documents until this is solved in Umbraco.

    Thanks,

    /Fredrik

  • dandrayne 1138 posts 2262 karma points
    Jan 19, 2010 @ 12:41
    dandrayne
    0

    Does anyone know if this was added as a work item?  It seems to be a genuine bug, can't find it in codeplex but don't want to duplicate it if it is there.

    Dan

  • Fredrik Sewén 39 posts 106 karma points
    Feb 10, 2010 @ 17:03
    Fredrik Sewén
    0

    Sorry, I should have mentioned it here.

    It was added to codeplex on the 20:th of November 2009

    http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=25408

    /Fredrik

  • Nicolai Winch Kristensen 50 posts 70 karma points
    Sep 13, 2011 @ 17:59
    Nicolai Winch Kristensen
    0

    Hi

    Has this been solved somehow - has the exact same problem as described.

    Kind Regards

    Nicolai

     

  • Johan 188 posts 380 karma points
    Aug 30, 2013 @ 16:02
    Johan
    0

    I'm running Umbraco 4.11.6 and got this problem. And removing umbraco.config did not solve it for me.

  • Rob Watkins 369 posts 701 karma points
    Jul 07, 2014 @ 13:54
    Rob Watkins
    0

    Just got this in 7.1.3 and like Johan removing the umbraco.config did not fix it; I had to protect the new parent.

    I assume that removing the new parent's protection straight away would fix it but as I was wanting the new parent protected anyway it wasn't an issue.

Please Sign in or register to post replies

Write your reply to:

Draft