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.