Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitecore updates a lot of items on smart publish

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!

like image 478
BerserkerDotNet Avatar asked Mar 02 '16 09:03

BerserkerDotNet


People also ask

Which is the fastest publishing mode in Sitecore?

Incremental Publish is the fastest way of publishing because Sitecore does not use resources to compare versions of the items that are in the publishing queue before publishing them.

How smart publish works in Sitecore?

Smart publish: When Smart publish is used, Sitecore checks the revision number of each item in master with web database and gets the list of items changed. It will publish only these changed items and ignore the items without any change. Hence this option will be fast. It does not use the publishing queue.

How does Sitecore publishing work?

When you work in Sitecore, the items you save are saved to the Master database. When you publish new items or updated items, the items are copied from the Master database to a publishing target, and from the publishing target, the website is launched. The default publishing target is the Web database.

What is publish related items Sitecore?

Publish Related Items are: Clone references – items that are clones of the selected item. Media references – media items that are related to the selected item. Alias references – items that are aliases of the selected item.


2 Answers

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.

like image 72
Henrik Avatar answered Oct 16 '22 19:10

Henrik


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.

like image 40
IvanL Avatar answered Oct 16 '22 20:10

IvanL