Skip to content

How does publishing work

Nikolay Mitikov edited this page Aug 8, 2017 · 2 revisions

What is publishing in Sitecore?

Publishing is the process of moving publishable content from the work-in-progress database to the publishing target.

When is content publishable?

Item is publishable when both points are true:

A) Is either in final workflow state or does not have any workflow assigned:

not_in_final

B) Does not have any publishing restrictions that prevent an item from being published:

publishing_restrictions

How does it find changes?

Publishing mode is a name for a logic that must find item changes in the whole database.

There are 3 modes by default.

Smart mode

Smart mode compares Revision field value between the source and target databases.

revision

The field value is changed to a new random guid value whenever an item is changed.

Having different revisions for the same item in different databases indicates an item change.

Drawback: whole item tree must be enumerated - meaning all items will sooner or later be loaded (slow with tons of content)

Incremental mode

Incremental mode uses PublishQueue table from source database.

Each item modification in source database results in a new row being added to PublishQueue table:

publish_queue

Incremental publish picks only new rows (not published previously) for publishing processing.

Once publishing is finished, rows are marked as published to the specific publishing target so that same data is not published twice.

This is achieved by saving last published row ID to Properties table:

last_published_stamp

Full publish

Publish everything no matter what. Most expensive mode.

How does publishing work?

Each publishing operation requires a set of steps:

  • Ensure vital system items present in publishing target (f.e. languages, templates)
  • Figure out the scope of changes
  • Ensure caches are up-to-date
  • Process each publishing candidate

A set of steps for each publishing candidate:

  • Raise publishing-related events
  • Check security
  • Transform virtual items (clones) to real ones
  • Figure out the exact action (publish/skip/remove)
  • Add related item to processing
  • Update publishing statistics

A lot of logic needs to be executed - a suitable place to use pipeline design pattern:

publishing_pipelines

publish pipeline shall be used for Publish operation in general

publishItem pipeline shall be used to process each publishing candidate

How many publish operations can run at once?

Only ONE publish operation is allowed to be executed to the specific target at once to prevent concurrent modifications (spoiling data).

If you see initializing message, 99 % there is another publishing being executed, so your one is forced to wait:

initialize

What about multiple CM servers?

Only ONE CM must be configured to perform publish.

All CM instances must have Publishing.PublishingInstance setting pointing to one Sitecore instance.

As a result, publish operation would be executed by the specific instance thanks to Event Queue magic.

Clone this wiki locally