umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.4k stars 2.66k forks source link

Block list not always updated on Save & Publish #10245

Open bjarnef opened 3 years ago

bjarnef commented 3 years ago

Based on Umbraco v8.12.2 I am sometimes experience issues with Block List content not being updated on frontend when clicking save and publish.

It seems the cache isn't updated in some cases.

After recycling the app pool the newly added block content appears on the frontend though.

Not sure there's an easy way to reproduce this as it doesn't always seems to happen.


_This item has been added to our backlog AB#12066_

bjarnef commented 3 years ago

We have noticed the rendered block list content not always is visible on frontend, when hitting "Save & Publish". However if going to "Published Status" dashboard in settings and click "Reload" button at Memory Cache, the content is available on frontend.

I wonder if something isn't refreshing the content correct regarding block list editor?

image

nul800sebastiaan commented 3 years ago

Thanks Bjarne, let me check at HQ what could be the problem here.. suspect some kind of cache refresher problem but it's outside of my area of expertise.

bjarnef commented 3 years ago

Great. I have another project upgraded to v8.13.0 where I see the same behaviour in the block list editor. It seems the reload memory cache is a temporary workaround for now, but not ideal.

Furthermore it seems this also may be related to nested block list editors.

nul800sebastiaan commented 3 years ago

Hey @bjarnef, sorry for the delay, we don't really have any feedback here other than that we've not seen this problem anywhere else. If you can make it happen in a somewhat consistent way in 8.13 then we'd be happy to look at it! It's very difficult to replicate people's setups on block editor (or nested content) so we're going to need a clean install with the setup you have and a way to reproduce the issue on that clean test install.

To achieve this, I would recommend you package up your document types and install them in a clean site and see if you can reproduce. At that point it should be pretty easy to figure out what's going on, but at the moment we really have very little to go on.

warrenbuckley commented 3 years ago

OK I have done a quick test and I cant seem to reproduce this @bjarnef so I think we will need exact reproduction details like @nul800sebastiaan

I changed only content in the outer blocklist and this published just fine, I also only changed content in the inner blocklist and that also worked fine.

My very basic nested block list partial view

@inherits Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Core.Models.Blocks.BlockListItem>
@using ContentModels = Umbraco.Web.PublishedModels;
@{
    var content = (ContentModels.Staff)Model.Content;
    var settings = (ContentModels.Staff)Model.Settings;
}

<h1>@content.StaffName</h1>
@foreach(var likeItem in content.Likes)
{
    var likeContent = (ContentModels.Likes)likeItem.Content;
    var likeSettings = (ContentModels.Likes)likeItem.Settings;

    <h2>@likeContent.Title</h2>
    <h3>@likeContent.Description</h3>
}
bjarnef commented 3 years ago

@warrenbuckley I will see if I can find some time to reproduce this and eventually on the starter kit.

One place I recall I had this issue was a "Block Map" which included a partial. I will see if I can reproduce on starterkit - maybe using "Products" or "Persons" instead.

@inherits Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Core.Models.Blocks.BlockListItem>
@using ContentModels = Umbraco.Web.PublishedModels;
@{
    var content = (ContentModels.BlockMap)Model.Content;

    var root = Umbraco.AssignedContentItem?.Root();
    var departmentArchive = root?.FirstChild<ContentModels.DepartmentArchive>();
    var departments = departmentArchive?.Children<ContentModels.Department>();
}

<div class="block-map">
    <div class="container">
        <div class="row">
            <div class="col-12 col-md-6 order-2 order-md-1">
                @Html.Partial("ImageMap", departments)
            </div>
            <div class="col-12 col-md-6 order-1 order-md-2">
                <div class="textblock-area">
                    @if (!string.IsNullOrWhiteSpace(content.Heading))
                    {
                        <h2>@content.Heading</h2>
                    }

                    <p>@Html.Raw(Html.ReplaceLineBreaks(content.Description))</p>

                    @if (content.Link != null)
                    {
                        <a href="@content.Link.Url" target="@(content.Link.Target ?? "_self")" class="btn btn-secondary">Read more</a>
                    }
                </div>
                <blockquote class="quote">
                    <p>@Html.Raw(Html.ReplaceLineBreaks(content.Quote))</p>
                </blockquote>
            </div>
        </div>
    </div>
</div>
warrenbuckley commented 3 years ago

Yes please let us know how you get on with some repro steps

bjarnef commented 3 years ago

I tried if I could reproduce this in starterkit using Umbraco v8.13.0 and debugging disabled. However I couldn't easily reproduce it although I tried with ModelsBuilder AppData and PureLive. I also tried updating the content data in the block itself and in the product properties.

Views/Partials/BlockList/Components/BlockLimitedProducts.cshtml

@inherits Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Core.Models.Blocks.BlockListItem>
@using ContentModels = Umbraco.Web.PublishedModels;
@{
    var content = (ContentModels.BlockLimitedProducts)Model.Content;

    var root = Umbraco.AssignedContentItem.Root();
    var products = root.Descendants<ContentModels.Product>().Take(6);
}

<div class="limited-products" style="background-color: gold; padding: 2rem; margin: 1rem;">

    <div style="text-align: center;">
        <h2>@content.Heading</h2>
        <p>@Html.Raw(Html.ReplaceLineBreaks(content.Description))</p>

        @if (content.Link != null)
        {
            <a href="@content.Link.Url" target="@(content.Link.Target ?? "_self")" class="button button--border--light_solid">Buy now</a>
        }
    </div>

    @Html.Partial("ProductList", products)
</div>

Views/Partials/ProductList.cshtml

@inherits Umbraco.Web.Mvc.UmbracoViewPage<IEnumerable<Product>>

<div class="product-list product-grid">
    @foreach (Product product in Model)
    {
        <a href="@product.Url()" class="product-grid__item" style="background-image: url('@product.Photos.Url()')">
            <div class="product-grid__item__overlay">
                <div class="product-grid__item__name">@product.ProductName</div>
                <div class="product-grid__item__price">@product.Price.ToString("F")</div>
            </div>
        </a>
    }
</div>
bjarnef commented 2 years ago

@warrenbuckley I have noticed this a few times on a v9.0.0 project I am working on, so I seems something it not updating NuCache on "Save & Publish".

In this case the block element I added to the block list wasn't in a nested block list though. As soon I refresh memory cache from NuCache dashboard it is shown on frontend.

And when I now afterwards add block elements to the block list they are shown right away. It seems to be periodically...

gabet1337 commented 2 years ago

A client of ours is experiencing similar issues as described here and it has happened a few times.

Recently the client updated block list content, saved and published the content and it was correctly displayed on the frontend. After refreshing in the back-office the content is no longer to be found and the history does not reflect the change but the change is still visible in the frontend.

The client runs Uno with Umbraco 8.16.0, which means we cannot refresh NuCache directly from the backoffice...

bjarnef commented 2 years ago

On a working project on v9.2.0 I have noted this as well. For this specific project it is not hosted on Umbraco Cloud, but using Azure Web Apps.

These two newly inserted image blocks.. and hitting "Save & Publish" these are not updated in frontend.

image

When I click "Reload" button under Memory Cache, the images are viisble in frontend.

image

The Image Block has a simple Image Picker (using Media Picker 3), a Link Picker (using Multi URL Picker) and a caption (textbox).

image

hfloyd commented 1 year ago

I have noticed this occasionally on an Umbraco 10.4.0 project as well. Sometimes I Save & Publish a node, but don't see the change reflected on the front-end until I do the "Memory Cache" reload.

Also, (maybe a different issue?) I have seen in a nested content block situation, if I copy a block, and paste it, then update the pasted block and "Save & Publish", some of the updates I made to the pasted block are not saved - they revert to the "pasted" settings.

Video showing issue (too big to upload to Github issues) Video example of issue

In this example, the data which is "lost" is in the third-level down of blocks (Grid Section > Row > Column Content)

bjarnef commented 1 year ago

I noticed this issue again today locally on a Umbraco v10.4.0

image

The block list element didn't appear on frontend after save & publish and the following returned 0:

@(Model.SidebarSections?.Count ?? 0)

I tried save and publish a few times, but didn't make a difference.

After reloading memory cache it showed up though and the abeforementioned code returned 1.

image

I guess there must be an edge case where save & publish doesn't refresh cache.

bjarnef commented 1 year ago

@nzdev you have made some changes / improvements for rebuild of NuCache. Maybe you have noticed this issue as well?

bjarnef commented 1 year ago

I just had this reported by the customer on a page, where a block isn't updated even save & publish multiple times. I also tried rebuilding memory cache and recycle environment, but didn't help.

image

image

For this block we had this following, but I think after upgrade/migration from Umbraco v9 to v10, the multiple media picker generates Images property as IEnumerable<MediaWithCrops> ... apparently it can't cast MediaWithCrops to Image media type.

@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListItem>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@using Umbraco.Cms.Core.Models;
@{
    var content = (ContentModels.BlockImageScroller)Model.Content;
    var settings = (ContentModels.BlockSettingsImageScroller)Model.Settings;

    var images = content.Images?.OfType<Image>().ToArray();

    bool showLightboxGallery = settings?.ShowGallery ?? false;
}

<p>Count: @images.Length</p>

@if (images.Length > 0)
{
    ...
}

so we needed to change to this instead:

var images = content.Images?.Select(x => x.Content).OfType<Image>().ToArray();
tormnator commented 10 months ago

We're running Umbraco 12.2 on Umbraco Cloud. A page containing a Block Grid with several blocks is published and displays correctly in the Development environment. We then transfer the page to Live. The page displays on Live, but one of the blocks is not rendered. I tried republishing on Live, editing the page in the backoffice on Live, adding other blocks, modifying the block which doesn't display, etc. All changes to the page show up, except the specific block which is still not rendered.

I then go into settings and reload the memory cache, and the missing block is immediately rendered.

This problem is not consistent, it's the first time (I think) we've encountered it. Other pages are fine.

bjarnef commented 6 months ago

I had a similar issue today when working with Block Grid and a reusable/global block, where a "normal" accordion block in Block Grid has a settings block, but the reusable/global block in a separate block grid reference by a block with a MNTP didn't have a settings block, so I got this:

image

It worked I changed

@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridItem<BlockAccordion, BlockSettingsAccordion>> 

to this in accordion block, but then the normal one wouldn't have the settings configuration to use.

@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridItem<BlockAccordion>>

I applied the settings block to the reusable/global block and save + publish, but still the settings udi was empty in the razor view.

However after I went the Settings > Published Status dashboard and rebuilt the memory cache it showed up.

Something funky is going on sometimes 😄