Try our conversational search powered by Generative AI!

FilterPublished method does not work correctly for content published without StartPublish on same HTTP request

Found in

EPiServer.CMS.Core 10.0.1

Fixed in

EPiServer.CMS.Core 10.6.0

(Or a related package)

Created

Feb 01, 2017

Updated

Mar 24, 2017

Area

CMS Core

State

Closed, Fixed and tested


Description

Steps to reproduce

  1. Install the Alloy Template and upgrade to latest version.
  2. Add the attached initialization file into the project.
  3. Run the site in DEBUG mode and set break point at the line 24 in the TestInitilization.cs.
  4. Create a new page in the edit mode and then publish it. If you edit an existing page, it always returns "false".

 public void Initialize(InitializationEngine context)
        {
            var events = ServiceLocator.Current.GetInstance<IContentEvents>();
            events.PublishedContent += DoSomething;
        }
 
        private void DoSomething(object sender, ContentEventArgs e)
        {
            if (e?.Content != null)
            {
                var filter = new FilterPublished();
                var value = filter.ShouldFilter(e.Content);
            }
        }

Expected: "value" should be "false".
Actual: "value" is "true".

Developer note: The filters use ITimeProvider to make sure there is a consistent time validation for a single request. Before CMS 10, the StartPublish was getting the same value as created date which was also based on the time provider. In CMS 10, the default value for StartPublish was added when content was published, but it used DateTime.Now instead of the request time. This fix changes to that StartPublish takes time for the ITimeProvider.