Copied to clipboard

Flag this post as spam?

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


  • Jesper Hauge 298 posts 487 karma points c-trib
    Mar 16, 2011 @ 14:53
    Jesper Hauge
    0

    UpdateDocumentCache doesn't update unpublished documents

    Hi all,

    This concerns a site running Umbraco 4.6.2, IIS 7 and .NET 4

    Examples on Unpublishing/Deleting nodes often uses code like the following:

    var doc = new Document(id);
    doc.Unpublish();
    umbraco.library.UpdateDocumentCache(doc.Id);
    doc.delete(true);

    Which seems to work fine when looking at things in the backend afterwards. But pages in frontend seems to ignore this when listing pages using xslt or umbraco.NodeFactory.Node.ChildrenAsList, which indicates it's a caching problem.

    So my question is - how comes library.UpdateDocumentCache doesn't help here? It does exactly what it's supposed to do when creating publishing documents. Also I noticed that the following code works perfectly:

    var doc = new Document(id);
    umbraco.library.UnPublishSingleNode(id);
    doc.delete(true);

    Notice that there's no call to library.UpdateDocumentCache(id) here.

    I'm tempted to report this as an issue in Codeplex since I find it confusing that you have to use different methods to handle the documentcache when creating and deleting documents via the API.

    What do you think?

    Regards
    Jesper Hauge

  • Michael Perry 11 posts 43 karma points
    Apr 13, 2011 @ 00:05
    Michael Perry
    1

    I am noticing this same behavior when unpublishing a document using the API.  Unpublshing the document using the API would not remove the document from umbraco.config unless I used umbraco.library.UnPublishSingleNode().  Using umbraco.library.UpdateDocumentCache(d.Id) and umbraco.library.RefreshContent() seemed to have no affect on the umbraco.config file.

    I am using Umbraco 4.5.2, IIS7 and .NET 4.0.

    Jesper's code above seems to be a valid workaround for me for now, but I still feel like this should be logged as a bug.

     

    Thanks,

    Mike

  • Lachlann 344 posts 626 karma points
    May 23, 2011 @ 23:06
    Lachlann
    0

    Hey all I am experiencing a similar issue, after using the Document method delete() node is deleted in the backend but usng umbraco.library.RefreshContent(); does not refresh the content in the front end.

    any one had a similar problem and found a solution?

     

    L

     

    ps: running umbraco v 4.5.2

  • Jesper Hauge 298 posts 487 karma points c-trib
    May 23, 2011 @ 23:14
    Jesper Hauge
    0

    Hi Lachlann,

    As I wrote in the first post the second code example actualle will delete a node, and the frontend will be updated afterwards.

    Regards
    Jesper Hauge

Please Sign in or register to post replies

Write your reply to:

Draft