OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.36k stars 2.37k forks source link

PublishLaterPartIndex sometimes has NULL ContentItemId #12706

Open mariojsnunes opened 1 year ago

mariojsnunes commented 1 year ago

Describe the bug

PublishLaterPartIndex sometimes has null values on ContentItemId, Published and Latest.

image

This causes the scheduler to find no items and thus the content will not be published. https://github.com/OrchardCMS/OrchardCore/blob/411206031d8d3e7626ed2f80c50c9bbfce958c9d/src/OrchardCore.Modules/OrchardCore.PublishLater/Services/ScheduledPublishingBackgroundTask.cs#L30-L33

To Reproduce

This has happened in prod a few times, but I couldn't reproduce it locally yet :/

But I've checked that other indexes for the same DocumentId are not affected. I've noticed a difference, for this index we are using part.ContentItem instead of contentItem directly. https://github.com/OrchardCMS/OrchardCore/blob/411206031d8d3e7626ed2f80c50c9bbfce958c9d/src/OrchardCore.Modules/OrchardCore.PublishLater/Indexes/PublishLaterPartIndexProvider.cs#L65-L77

Maybe there is an issue with var part = contentItem.As<PublishLaterPart>(); and changing to contentItem would solve the issue? Any idea why is this happening?

mariojsnunes commented 1 year ago

I've created a PR with proposed changes

hishamco commented 1 year ago

FYI which version you are using, we already updated the OC.PublishLater module in 1.4

mariojsnunes commented 1 year ago

FYI which version you are using, we already updated the OC.PublishLater module in 1.4

This issue happened with 1.4.0-preview-16817, what's the best way to check the code of this version? I've update to the latest 1.5.0-preview over the weekend, so I'm not sure if it's still occurring now, good catch.

hishamco commented 1 year ago

If you can test it in the latest bit it will be great

jtkech commented 1 year ago

Yes, the items, already marked to be "published later" before the upgrade, should be edited and be "published later" again to populate the index table.

We may need an Admin tool to update index tables, I think there is an opened issue around this.

sebastienros commented 1 year ago

Migration step?

jtkech commented 1 year ago

Okay I will suggest something.