Mark's Sitecore Blog

PublishAgent skipping all items when CheckSecurity is activated

We ran into an issue when trying to publish the entire site on a regular basis using PublishAgent. We have it set up to publish the entire site every hour.

<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="01:00:00">
 <param desc="source database">master</param>
 <param desc="target database">web</param>
 <param desc="mode (full or smart or incremental)">smart</param>
 <param desc="languages">en</param>
 </agent>

We noticed though, that new items weren’t being published. The publish log showed the following:

ManagedPoolThread #14 13:12:13 INFO PublishAgent started (source: master, target: web, mode: Smart, languages: en)
ManagedPoolThread #14 13:12:13 INFO Asynchronous publishing started. Job name: Publish to 'web'. Languages: en
10580 13:12:13 WARN SitePublish detected. PublishContext was overridden with DisableDatabaseCaches=True.
10580 13:12:13 INFO Starting [Publishing] - ProcessQueue
10580 13:13:04 INFO Finished [Publishing] - ProcessQueue in 50986 ms
10580 13:13:04 INFO Publish Mode : Full
10580 13:13:04 INFO Created : 0
10580 13:13:04 INFO Updated : 0
10580 13:13:04 INFO Deleted : 0
10580 13:13:04 INFO Skipped : 36712

Publishing manually was working fine.

After searching for a while, we found out the reason for PublishAgent skipping all items was quite obvious: We have set Publishing.CheckSecurity=true to make sure users could only publish the items they were allowed to. Unfortunately PublishAgent runs as sitecore\Anonymous who of course doesn’t have sufficient rights.

To solve this problem, you can implement a class that inherits PublishAgent and overrides the Run method. Then use UserSwitcher to switch to a user that has the appropriate rights.

TwitterGoogle+Facebook 

One thought on “PublishAgent skipping all items when CheckSecurity is activated

  1. Vaibhao Chawale

    Hi Mark,

    Thanks a lot for this , When i was about to lose my hope and head to Sitecore Support i found this.

    Due to this setting i am getting all my logs proper just data was not getting transferred from master to web database, this setting triggered final solution. thank you

    You are a savior.

    – Vaibhao C

Leave a Reply

Your email address will not be published. Required fields are marked *