Copied to clipboard

Flag this post as spam?

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


  • Jon Dunfee 199 posts 468 karma points
    Feb 14, 2014 @ 00:05
    Jon Dunfee
    0

    Still have to publish on destination server

    Say I have 3 pages with a macro generating a nav. [Item1], [Item2], [Item3]

    We use Courier to deploy from environment 1 to environment 2.  Rename [Item2] to [ItemTwo] and deploy the updated node.

    I expect the nav to reflect as [Item1], [ItemTwo], [Item3]. Instead it shows up as [Item1],[Item3].  

    [ItemTwo] disappears entirely until I go into the back-office of environment 2 and perform a Save & Publish on the updated [ItemTwo] node.  I can cycle the app pool, reboot the server - doesn't matter. I can even access the page (domain/ItemTwo) just fine. None of the macros see the page until the page is republished.

    Looking at the courier log, the PublishDocument event fires and I don't see any other errors.  What's the deal??  There a hidden setting or something in Courier or Umbraco to actually perform the publish doc after a Courier deployment??

    This is Umbraco v6.1.6 using Courier 2.7.8.36. The navigation macro is using XSLT.  In the umbracoSettings.config I have XmlCacheEnabled, XmlContentCheckForDiskChanges and ContinouslyUpdateXmlDiskCache set to False.  The site is well over 25k nodes.

  • Jon Dunfee 199 posts 468 karma points
    Feb 25, 2014 @ 22:36
    Jon Dunfee
    0

    I've determined this impact is only to XSLT-based macros and after a Courier deployment I can Republish Entire Site at the root level to reset the cache, but users using Courier will not have access to the target environment so I need to automate this or ??  I rewrote the macro to Razor and it's working fine; unfortunately, the performance is terrible for what I'm trying to output.  Do I need to create a ItemEventProvider for Courier to kick off a umbraco.library.UpdateDocumentCache(id) for each Document published?

    I started down this path; however, UpdateDocumentCache is listed as obsolete stating this is no longer necessary.  I don't know if it's feasible to kick off an umbraco.library.RefreshContent() after the entire package is complete as it takes several minutes since I have XmlCacheEnabled set to false.

     

  • Jon Dunfee 199 posts 468 karma points
    Mar 02, 2014 @ 19:06
    Jon Dunfee
    101

    Here's my solution. If anyone has a better one, I'm all ears!

    using System;
    using Umbraco.Core;
    using Umbraco.Courier.Core;
    using Umbraco.Courier.Core.Diagnostics.Logging;
    using Umbraco.Courier.Core.Enums;
    using Umbraco.Courier.Core.ProviderModel;
    using Umbraco.Courier.ItemProviders;
    
    namespace MyNamespace.Umbraco.Events
    {
        public class EventSubscriber : IApplicationEventHandler
        {
            private void UpdateDocumentCache(object sender, ItemEventArgs e)
            {
                //this is Courier Item, not a native umbraco document
                var d = e.Item as Document;
    
                //the current provider used 
                var provider = sender as ItemProvider;
    
                //queue the event "UpdateDocumentCache" in the DBtransactionComplete queue
                //this will then be executed after the DB transaction is done.
                if (d != null && d.Published && provider != null)
                    provider.ExecutionContext.QueueEvent("UpdateDocumentCache", d.ItemId, null,
                                                         EventManagerSystemQueues.DBTransactionComplete);
            }
    
            #region IApplicationEventHandler
    
            public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication,
                                                 ApplicationContext applicationContext)
            {
            }
    
            public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication,
                                              ApplicationContext applicationContext)
            {
            }
    
            public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication,
                                             ApplicationContext applicationContext)
            {
                DocumentItemProvider.Instance().PostProcessed +=
                    new EventHandler(UpdateDocumentCache);
            }
    
            #endregion
        }
    
    
        public class CourierUpdateDocumentCache : ItemEventProvider
        {
            public override string Alias
            {
                get { return "UpdateDocumentCache"; }
            }
    
            public override void Execute(ItemIdentifier itemId, SerializableDictionary parameters)
            {
                Guid g;
                //if the itemId is a valid Guid we will fetch a umbraco document from it
                if (Guid.TryParse(itemId.Id, out g))
                {
                    try
                    {
                        //get the native umbraco document object
                        var d = new umbraco.cms.businesslogic.web.Document(g);
                        var cs = ApplicationContext.Current.Services.ContentService;
                        var c = cs.GetById(d.Id);
                        cs.Publish(c); // let the magic happen
                    }
                    catch (Exception ex)
                    {
                        //logging of errors
                        RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateDocumentCache", ex.ToString(),
                                                          LogItemEntryType.Error);
                    }
                }
            }
        }
    }

    Coincidentally, there is one line that is using an obsolete call (var d = new umbraco.cms.businesslogic.web.Document(g)), but I didn't spend a great deal of time to figure out how else to take the Courier guid and translate to a Content object since IDs are numeric.  When I look at the Document object it's executing a direct SQL scalar call, so no translation to the preferred object like many other obsolete references.

  • Jon Dunfee 199 posts 468 karma points
    Mar 08, 2014 @ 04:46
    Jon Dunfee
    1

    Are you KIDDING me?!?!  I just stumbled onto this post: http://www.growingwiththeweb.com/2012/10/making-umbraco-courier-publish-on.html Well, all this effort was a learning exercise in attaching events to Courier, I suppose.

    <configuration>
      <appSettings>
        <add key="CourierRepublish" value="true" />
      </appSettings>
    </configuration>

    Yeah, that's much easier.  I'm surprised it's not documented in the official docs sure woulda saved me some long days/nights.

  • Jon Dunfee 199 posts 468 karma points
    Mar 16, 2014 @ 20:36
    Jon Dunfee
    0

    It wasn't that easy afterall.  The web.config setting only publishes single file deployments; it does NOT apply to revisions.  So, my effort was not a waste as I had to revert to using my event handler.  I may play around with it considering someone has to "install" the revision on the target server, I may revert to the web.config setting again and just add to the workflow process a step to tap the "Republish entire site" on the root node.

  • Jeric Yuen 332 posts 505 karma points
    Mar 21, 2017 @ 17:55
    Jeric Yuen
    0

    Hey Jon,

    I'm having similar issues and i'm trying to do the same. But I'm stuck at

    DocumentItemProvider.Instance().PostProcessed

    I can't seems to be able to find .Instance() not sure why. I've tried searching it in the forum but can't find similar thing

    Any idea?

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft