Copied to clipboard

Flag this post as spam?

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


  • Topic author was deleted

    Apr 22, 2013 @ 21:42

    Strange Publish\Cache behavior in 4.11.x

    Any had any issues with 4.11.x regarding the following?

    - Document is created dynamically (Document.MakeNew...)

    - Document.publish() is called.

    - Custom before_publish event is run.

    - Cache does not update.

    - Tried to use umbraco.library.UpdateDocumentCache after .publish() to try to motivate it to update.  Does not update cache.

    - umbraco.library.refreshContent() DOES work, but it updates the entire site (slow)

    ----

    If I use the GUI, it works just fine.  Only when I programattically create the docs and publish.   Using the GUI defats the purpose.

     

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Apr 23, 2013 @ 12:15
    Dave Woestenborghs
    0

    Can you post the entire code ?

  • Comment author was deleted

    Apr 23, 2013 @ 13:56

    Here are the relavent parts:

    Document previewDocument = Document.MakeNew(rootDocument.Text, DocumentType.GetByAlias(rootDocument.ContentType.Alias), currentUser, previewsFolder.Id);

    copyProperties(rootDocument, previewDocument);
    previewDocument.getProperty("previewRootID").Value = rootDocument.Id;
    previewDocument.getProperty("customURL").Value = previewDocument.Text + " Preview";

    previewDocument.Publish(currentUser);

    umbraco.library.RefreshContent();//works but refreshes the entire site

     

    The following does not work in lieu of umbraco.library.RefreshContent():

     

    Document previewDocument = Document.MakeNew(rootDocument.Text, DocumentType.GetByAlias(rootDocument.ContentType.Alias), currentUser, previewsFolder.Id);

    copyProperties(rootDocument, previewDocument);
    previewDocument.getProperty("previewRootID").Value = rootDocument.Id;
    previewDocument.getProperty("customURL").Value = previewDocument.Text + " Preview";

    previewDocument.Publish(currentUser);

    umbraco.library.UpdateDocumentCache(previewDocument.Id); //nope

    umbraco.library.UpdateDocumentCache(previewDocument.ParentId); //nope
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Apr 24, 2013 @ 13:46
    Dave Woestenborghs
    0

    What does the beforepublish handler do ? Because the second code sample should work, even without publishing the parent node.

     

     

  • Comment author was deleted

    Apr 24, 2013 @ 13:55

    The before publish handler writes a dynamic entry into urlRewriting.config.

    I have no issues with the handler from the GUI (regular publish button), but only when invoking .Publish() in the manner above.

    I'm assuming .Publish() is syncronous, but I could see an issue if it were async.

    I'm presently going with the:

    umbraco.library.RefreshContent();

    code, but it feels expensive on our very large site.

    IMHO I don't see how anything in the before_publish event handler would affect downstream static methods that are simply just supposed to refresh the cache (other than a cancel of the event itself).

    Even so, if I refresh the entire site, the new node shows up implying that the node DID publish.

    Not a show stopper, but noted as an oddity.

Please Sign in or register to post replies

Write your reply to:

Draft