Sitecore updates a lot of items on smart publish
Asked Answered
P

2

9

I'm using Sitecore 8.0 Update 5. Each time I'm doing a "Smart" publish with languages other than English I can see that thousands of items being updated.

Job started: Publish to 'web'
Items created: 0
Items deleted: 0
Items updated: 56207
Items skipped: 13057
Job ended: Publish to 'web' (units processed: 69258)

I've enabled tracing and in the logs I can see that Sitecore updateds shared fields of those items

##Publish Item: Name=sitecore, Uri=sitecore://master/{11111111-1111-1111-1111-111111111111}?lang=zh&ver=1, Operation=Updated, ChildAction=Allow, Explanation=Shared fields were published.
##Publish Item: Name=templates, Uri=sitecore://master/{3C1715FE-6A13-4FCF-845F-DE308BA9741D}?lang=zh&ver=1, Operation=Updated, ChildAction=Allow, Explanation=Shared fields were published.
##Publish Item: Name=List Manager, Uri=sitecore://master/{D2833213-CB77-431A-9108-55E62E4E47FD}?lang=zh&ver=1, Operation=Updated, ChildAction=Allow, Explanation=Shared fields were published.

And the list goes on like that for pretty much every item in the tree. Armed with dotPeek I was able to find a method in publishing pipeline that is responsible for determining publish action:

private void HandleSourceVersionNotFound(Item sourceItem, PublishItemContext context)
{
  Assert.ArgumentNotNull((object) sourceItem, "sourceItem");
  Item targetItem = context.PublishHelper.GetTargetItem(sourceItem.ID);
  if (targetItem != null)
  {
    Item[] versions = targetItem.Versions.GetVersions(true);
    if (versions.Length > 0 && versions.Any(v => v.Language != sourceItem.Language)) || Settings.Publishing.PublishEmptyItems)
      context.Action = PublishAction.PublishSharedFields;
    else
      context.Action = PublishAction.DeleteTargetItem;
  }
  else if (Settings.Publishing.PublishEmptyItems)
    context.Action = PublishAction.PublishSharedFields;
  else
    context.AbortPipeline(PublishOperation.Skipped, PublishChildAction.Skip, "No publishable source version exists (and there is no target item).");
}

Here we can see that it checks item versions and if there are versions on language other than English it sets action to PublishAction.PublishSharedFields. Settings.Publishing.PublishEmptyItems is set to false in my case, so this should not trigger shared fields publish.

I thought that the only "system" items with non-English version in my solution were languages, but when I looked on one of the item from the logs I discovered a really interesting thing: Sitecore default languages

These appears to be Sitecore "default" languages.

This behavior causes a performance problem with publishing when I enable Language Fallback module. (https://marketplace.sitecore.net/en/modules/language_fallback.aspx)

My questions are:

  1. Is this an expected behavior for Sitecore to push shared fields each time when you publish?
  2. Is this an expected behavior for Sitecore to push shared fields on system items when they have versions only on these default languages?
  3. How can I disable those default languages and remove versions on these languages? (Powershell?)
  4. What are the implications of removing these default languages?
  5. Is there anything that I'm doing wrong that can cause this kind of behavior?

UPD. On a different environment where it goes over 100k items threshold and triggers full index rebuild, which is pretty expensive operation. (With or without language fallback)

Thanks in advance!

Protomartyr answered 2/3, 2016 at 9:8 Comment(3)
What's the performance problem? How much of an increase are you seeing?Koziel
With language fallback module disabled it's not much 20-30 seconds for 60k items. If language fallback is enabled it's nightmare, it takes over an hour for the same number of items.Protomartyr
You are unlikely to receive comprehensive answers to all of your questions at once. I would split this into at least two separate questions: (1+2+5), (3+4). Maybe you should ask the Language Fallback performance question separately, too.Disorganization
G
2

How can I disable those default languages and remove versions on these languages?

If the language is registered under /sitecore/system/Languages, Sitecore should remove all item version, for the language, if you remove the language.

If the language is not registered (or Sitecore, for some reason, fails to remove it when you remove it) under /sitecore/system/Languages, do a database cleanup (Control Panel > Database > Clean Up Databases). Sitecore will remove any version of items that are in a language that is not registered.

What are the implications of removing these default languages?

Unless you plan on using those languages in the future, no real implication.

Griseous answered 13/7, 2017 at 8:45 Comment(0)
K
1

Is this an expected behavior for Sitecore to push shared fields each time when you publish? => No but the code you've found isn't used for every item. That action occurs when the Source Version isn't found ea the item exists in web but not in master. That's why it's either publish shared fields (in case other versions do exist) or delete the item completely from web (because it no longer exists in master).

Is this an expected behavior for Sitecore to push shared fields on system items when they have versions only on these default languages? => I'm unable to answer this question as is without deeper investigation for which I do not have time at this point I'm sorry.

How can I disable those default languages and remove versions on these languages? (Powershell?) => These languages aren't registered, they're showing up because these items do have a version in those languages. So if you remove the versions of all system items in those languages they'll no longer show up. You can create a version in any language even a non-existing one through code.

What are the implications of removing these default languages? => Any content editors that are using that language might suddenly see english (or a leftover language) instead of their preferred set Sitecore Editing language. Beyond that it should not matter.

Is there anything that I'm doing wrong that can cause this kind of behavior? => Not that I can see from what you've presented thus far.

Koziel answered 9/3, 2016 at 16:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.