After witnessing the issue with my own eyes when an item just created and not pushed via workflow was magically showing up in production after a few minutes, I decided to investigation Sitecore configuration. This revealed a PublishAgent that was enabled to run frequently, but nothing else.
<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="00:01:00"> <param desc="source database">master</param> <param desc="target database">web</param> <param desc="mode (full or incremental)">incremental</param> <param desc="languages">en, da</param> </agent>
After reproducing this on a local single server instance, I’ve narrowed it down to the “languages” parameter being the issue.
By default all PublishAgents configured with both “English” and “Danish” languages processed. What happens within the PublishAgent is pretty interesting.
1. The “languages” parameter (“en, da”) is parsed with the following code:
private static List<Language> ParseLanguages(string languages) { List<Language> list = new List<Language>(); foreach (string str in languages.Split(new char[] { ',' })) { if (str.Length > 0) { list.Add(Language.Parse(str.Trim())); } } return list; }
2. Down below, the Parse() method calls Language.TryParse() which basically boils down to the following checks:
if (LanguageManager.IsValidLanguageName(name)) if (LanguageManager.LanguageRegistered(name)) if (LanguageManager.RegisterLanguage(name))
If all these checks pass, the language name is considered to be valid. What’s interesting here is that even languages that are not created/registered within Sitecore under /system/languages will be parsed successfully. In our case there is no language with ISO code “da” created/registered in Sitecore, however, as far as Language.TryParse() is concerned, this language is valid and will be passed onto the publisher.
The publisher will try and get an item in “da” language from ItemManager for further processing. Due to the nature of Sitecore to decouple items from versions, this operation will actually return an item. This item will be returned as “empty” or “naked” with no versions, but there will be an instance.
So the publisher will process this item and treat it as “approved” and publish it to the target database.
While we can speculate on whether this is expected behavior or not, there is an easy solution for this problem. Simply make sure your PublishAgent is not configured to process any languages that do not exist within Sitecore. For our example this means modifying the “languages” parameter:
<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="00:01:00"> <param desc="source database">master</param> <param desc="target database">web</param> <param desc="mode (full or incremental)">incremental</param> <param desc="languages">en</param> </agent>
Hope this helps.
5 comments:
Yeah, we had a similar problem a while ago where we had some pages (but not all) in Spanish. If you ran a publish operation and checked Spanish everything got published. We were instructed by support to change the setting Publishing.PublishEmptyItems to false in the web.config. Sounds like maybe that would help here?
Kyle,
That's a good question.
Last time I checked there were some system items in Sitecore with no versions, so "Publishing.PublishEmptyItems=false" would unpublish those from the web database, which may cause unexpected behavior, but this might have been addressed.
I will have to double check with the tech support on this.
Which version of Sitecore do you have?
Alex,
We're running Sitecore 6.4.1 rev.110324. If it helps at all, the support ticket number associated with this is 334623. From this it appears that we were running 6.2 rev. 100701 at the time the problem was addressed (about a year ago).
Hey Alex,
We are running into the same issue...
We are running a multi lingual website, so we have something like this in the web config...I have three versions available
en, pt, es
As you said, if I add only en and remove pt and es from agent type...will it make any difference in the site behavior.
One more thing is that I already added the setting of publishing.publsihempty items to false...this doesn't solve the issue..
Any help would be greatly appreciated.
Thanks in advance.
The setting publishing.publishempty items value as false solved my issue.
Thanks Alex.
Post a Comment