We are using the new Sitecore Publishing Service (SPS) and trying to hook into the BulkPublishingEnd event. We have the following patch:
<publishEndResultBatch>
<processor type="Foobar.Feature.Website.Pipelines.PublishBatchResultProcessor, Foobar.Feature.Website"
patch:after="*[@type='Sitecore.Publishing.Service.Pipelines.BulkPublishingEnd.RaiseRemoteEvents, Sitecore.Publishing.Service']" />
</publishEndResultBatch>
I verified that the config is correct:
<publishEndResultBatch patch:source="Sitecore.Publishing.Service.config" argsType="Sitecore.Publishing.Service.Pipelines.BulkPublishingEnd.PublishEndResultBatchArgs">
<processor type="Sitecore.Publishing.Service.Pipelines.BulkPublishingEnd.RaiseRemoteEvents, Sitecore.Publishing.Service">
<param name="remoteEventCacheClearingThreshold">1000</param>
<param name="targetCacheClearHistory" ref="publishing.service/targetCacheClearHistory"/>
</processor>
<processor patch:source="z-PublishPipeline.config" type="Foobar.Feature.Website.Pipelines.PublishBatchResultProcessor, Foobar.Feature.Website"/>
</publishEndResultBatch>
The process runs correctly and reports on the items that were published. However, when I access the items directly in the target DB, I'm getting back the pre-updated item:
var db = Sitecore.Configuration.Factory.GetDatabase(args.TargetInfo.TargetDatabaseName);
var item = db.GetItem(publishedItem.EntityId.ToID());
My results in the immediate window after stepping through the code above are as follows:
args.Batch[0].Metadata.AsModified().ModifiedFields.ToArray()[0]
{Sitecore.Framework.Publishing.Manifest.FieldResult}
ChangeType: Modified
FieldId: {8cdc337e-a112-42fb-bbb4-4143751e123f}
Language: "en"
OriginalValue: "0829f0a6-260d-4a74-b7c2-0e27b063845a"
Value: "e0b4938c-4d6a-4891-94ab-b5d606a6df01"
Version: 1
item.Fields["{8cdc337e-a112-42fb-bbb4-4143751e123f}"].Value
"0829f0a6-260d-4a74-b7c2-0e27b063845a"
In my Process, I'm also initiating a re-index of a related item, using IndexCustodian.Refresh(...)
. When the re-index runs, it too has the original revision of the published items.
If I create a new item and publish, I get back the newly created item, in both instances, like I expect.
Is this intended behavior? Am I missing something in my config? Maybe the cache isn't getting cleared correctly? Is there another location in the pipeline that I can hook into and get both:
a) a list of changed items
b) context after the items have been updated and the cache cleared.