Copied to clipboard

Flag this post as spam?

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


  • Chris 13 posts 53 karma points
    Jun 30, 2015 @ 06:39
    Chris
    0

    U7: Publish At / Unpublish At [BUG]

    Hi all,

    I'm experiencing some issues with the auto Publish At / Unpublish At functionality in Umbraco version 7.2.6

    The Publish At function fails to make the page available after the datetime has passed. The backoffice registers the page as published, but with the "Oops: this document is published but is not in the cache (internal error)" message. This is fixed when someone manually fires the 'Republish Entire Site' function which then makes the page accessible.

    The Unpublish At function also registers the page as unpublished in the backoffice after the set datetime but the page is still accessible on the website until someone manually fires the 'Republish Entire Site' function, then the page is unpublished properly and inaccessible.

    I've tried a number of workarounds to no avail, including adding ContentServicePublished / ContentServiceUnPublished events that try to 'Republish Entire Site' on auto pub/unpublish. I've listed the code below:

        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            base.ApplicationStarted(umbracoApplication, applicationContext);
            ContentService.Published += ContentService_Published;
            ContentService.UnPublished += ContentService_UnPublished;
        }
        void ContentService_Published(global::Umbraco.Core.Publishing.IPublishingStrategy sender, PublishEventArgs<IContent> e)
        {
            bool isAutoPublish = false;
            foreach (var item in e.PublishedEntities)
            {
                if (item.ReleaseDate.HasValue && (item.ReleaseDate.Value - DateTime.Now).TotalMinutes < 10)
                {
                    isAutoPublish = true;
                }
            }
            if (isAutoPublish)
            {
                umbraco.cms.businesslogic.web.Document.RePublishAll();
                umbraco.library.RefreshContent();
            }
        }
        void ContentService_UnPublished(Umbraco.Core.Publishing.IPublishingStrategy sender, PublishEventArgs<IContent> e)
        {
            bool isAutoUnpublish = false;
            foreach (var item in e.PublishedEntities)
            {
                if (item.ExpireDate <= DateTime.Now)
                {
                    isAutoUnpublish = true;
                }
            }
            if (isAutoUnpublish)
            {
                umbraco.cms.businesslogic.web.Document.RePublishAll();
                umbraco.library.RefreshContent();
            }
        }
    

    I realise 'umbraco.cms.businesslogic.web.Document.RePublishAll();' is obsolete but I had to try it seeing 'umbraco.library.RefreshContent();' wasn't working for me (in Azure).

    I also noticed is that the .ReleaseDate property is always null, making it very difficult to determine whether an item was published manually or automatically published via the Publish At function. Is there another way to determine the auto published nature of the item in this context?

    Steps to recreate all of the above issues:

    1. In the backoffice, create a page node anywhere, populate it with any misc content, then hit Save and Publish. Visit the URL to see the page live.
    2. Back in the backoffice, select an Unpublish At datetime for a few mins from now.
    3. Wait it out and hit the expected URL for a while after the scheduled datetime, the page should still be incorrectly accessible as described above. Refresh the backoffice to see that Umbraco registers the page as unpublished, yet the page still renders.
    4. Click 'Republish Entire Site' and try the page again, it should be properly unpublished.
    5. Create a new node/page and just hit Save this time, not Save and Publish. Hopefully you can determine the expected URL, it'll help to test.
    6. Set a Publish At datetime to a few mins from now. Hit the expected URL to see the page correctly not load or exist.
    7. Wait it out and hit the expected URL for a while after the scheduled datetime and see if the page loads. Did the page load?
    8. Check in the backoffice to see that the node is registered as published but doesn't resolve on the site. You may see the "Oops: this document is published but is not in the cache (internal error)" message displayed.
    9. Republish the entire site again and access the page, it should load fine now.

    I hope to find a solution to these issues as scheduled content are integral. I'd even accept a hack job / workaround at this point seeing I've already invested much into this project build.

    Looking forward to hearing from anyone.

  • Chris 13 posts 53 karma points
    Jun 30, 2015 @ 07:12
    Chris
    0

    I'm also thinking about disabling the XML cache altogether but I fear that it may slow the site down too much - but I have CDN options so I might be able to get away with it if it solves the issues.

  • Paul Sterling 718 posts 1534 karma points MVP 8x admin c-trib
    Jul 03, 2015 @ 01:06
    Paul Sterling
    0

    @Chris

    Great post with details. The most obvious cause would be if you were using multiple instances in WebSites, which is not currently supported without very specific configuration.

    If you could confirm you are running on a single instance and, if not, make sure that's how your WebSites scale is configured.

    The good news is that with 7.3.0+ you will be able to run with multiple instances without much additional work. Have a look at Shannon's excellent Codegarden session to get an idea of what's coming:

    http://stream.umbraco.org/video/11665943/umbraco-load-balancing

  • Chris 13 posts 53 karma points
    Jul 03, 2015 @ 01:55
    Chris
    0

    Thanks for the informative reply Paul.

    We are running Umbraco on an Azure Web App with auto scale off so it is running as a single instance currently.

    Azure web apps have an internal traffic manager by design which allows for immutable deployment slots and switching in new deployments through production. So currently our user would browse to the azurewebsites URL, which hits an internal traffic manager and goes to our production slot which is a single instance site at this moment.

    I'll have time to watch that video a little later today, but version 7.3.0 sounds more tailored for Azure websites from the sound of it. I see the target release date is 12 June 2015, hopefully it will be released soon.

  • Chris 13 posts 53 karma points
    Jul 03, 2015 @ 02:42
    Chris
    0

    I just turned off Umbraco's XML cache and redeployed to the Azure website and the scheduled publish/unpublish functionality still didn't work without a human to manually click "Republish Entire Site".

    Is there any sort of workaround to bypass this bug? I noticed this bug also occurs when testing locally so maybe it's not just limited to Azure Websites (will edit the initial thread post).

    One thing that I found very curious is that even with XML cache turned off, the Umbraco backoffice still gives me the "Oops: this document is published but is not in the cache (internal error)" message after the unpublished page should have been auto published after the date.

    Which cache is it actually talking about?

  • Rik Helsen 670 posts 873 karma points
    Jul 03, 2015 @ 07:44
    Rik Helsen
    0

    Probably the memory version of the very same cache you would otherwise also store on disk. if i recall correctly, the disk version of the cache is only there to speed up recycle times (reading it, and then keeping it in memory)

  • Chris 13 posts 53 karma points
    Jul 07, 2015 @ 00:58
    Chris
    0

    Thanks for the reply Rik.

    I guess my questions may have to be:

    1. Is there any way for the ContentServicePublished / ContentServiceUnPublished events to differentiate between the nodes that were scheduled and those that were manually un/published?
    2. Is there a sure-fire method to republish the entire site from the backend code that replicates the onclick event of the manual 'Republish Entire Site' function?
    3. More on point 2, is there a way to flush the in memory cache programmatically without touching the web.config?
Please Sign in or register to post replies

Write your reply to:

Draft