Copied to clipboard

Flag this post as spam?

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


  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Dec 23, 2016 @ 09:45
    Jeroen Breuer
    0

    Preview suddenly stopped working

    Hello,

    Suddenly on our production environment preview stopped working. On our acceptance environment it is working. It has worked before, so I'm not sure why it stopped working.

    On the healthcheck I saw the XML Data Integrity had errors, but after fixing that the preview still didn't work.

    The preview does some special tricks you can read about here: http://24days.in/umbraco-cms/2016/umbraco-edge-case-stories/#preview

    Even though we do some special tricks it should still work. Pages without a ContentFinder and UrlProvider do work so that is the first thing I investigated. Most of them look like this:

    public string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
    {
        var targetPublishedContent = umbracoContext.ContentCache.GetById(id);
    
        if (targetPublishedContent != null)
        {
            Models.ContentModels.Language language;
            var contentRepository = DependencyResolver.Current.GetService<IContentRepository>();
    
            language = !umbracoContext.IsFrontEndUmbracoRequest
                ? contentRepository.GetAllLanguageContainers().FirstOrDefault()
                : contentRepository.GetCurrentLanguageContainer();
    
            if (language != null)
            {
                return umbracoContext.UrlProvider.GetUrl(language.Id).EnsureEndsWith("/")
                        + this.GetUrlSegment(targetPublishedContent, language.GetCultureCached().Name);
            }
        }
    
        return null;
    }
    

    I think somehow targetPublishedContent is null and that is why it isn't returning the URLs. Any idea what this could happen and only on production?

    I'm using Umbraco 7.5.3. Could an upgrade to 7.5.6 help?

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Dec 27, 2016 @ 10:47
    Jeroen Breuer
    100

    It seems that our runtime cache was working a bit too good. Replaced some code with request cache and now preview also seems to be working again on pages that use a ContentFinder and UrlProvider.

    Maybe something changed between Umbraco 7.4 and 7.5, because there it did work with the runtime cache.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft