Sitecore users edit item creates new version

核能气质少年 提交于 2019-12-05 21:47:43

Here is the code responsible for creating new versions while editing Sitecore items:

public Item StartEditing(Item item)
{
  Error.AssertObject((object) item, "item");
  if (!Settings.RequireLockBeforeEditing || Context.User.IsAdministrator)
    return item;
  if (this._context.IsAdministrator || StandardValuesManager.IsStandardValuesHolder(item) || !this.HasWorkflow(item) && !this.HasDefaultWorkflow(item) || !this.IsApproved(item))
    return this.Lock(item);
  Item obj = item.Versions.AddVersion();
  if (obj != null)
    return this.Lock(obj);
  else
    return (Item) null;
}

Apparently Sitecore creates new version if item is in a final state of any workflow unless user is administrator.

You could try to change the RequireLockBeforeEditing setting but it will disable not only new version functionality but the locking functionality as well.

this is Sitecore default behaviour for locking.

Sitecore uses item locking to ensure that two different users can‘t edit the same item at the same time. If two or more users somehow managed to edit the same item simultaneously, only the changes that were made by the user who clicked Save last will be available. All the other changes will be lost. Item locking is a system whereby you lock the item you are editing and prevent other users from editing this item until you unlock it again after you have finished editing the item.Item locking works differently depending on the tools that you are using. In the Page Editor, you can lock an item before you start to edit it.In the Content Editor, you must lock an item before you can edit it.

You can find more about locking Here

Please also look at this settings from web.config :

     <!--
     REQUIRE LOCK BEFORE EDITING
        If true, the user must have a lock on a document before
        he can edit it, otherwise it is always ready for editing

      -->
     <setting name="RequireLockBeforeEditing" value="true"/>

    <!--
        KEEP LOCK AFTER SAVE FOR ADMIN USERS
        Set this value to true if you want to Administrator users to keep the lock on     an item after saving
        it in the Page Editor.
        Notice: For regular users, the "Keep Lock After Save" item in the core database will determine whether
        to keep the lock or not.
        Default value: false
   -->
    <setting name="KeepLockAfterSaveForAdminUsers" value="false"/>
    <!--
   AUTOMATIC LOCK ON SAVE
        If true, the a lock is automatically taken on an item
        when a user saves the item.
   -->
  <setting name="AutomaticLockOnSave" value="false"/>
    <!--
  AUTOMATIC UNLOCK ON SAVED
        If true, the a saved item is automatically unlocked after
        saving.
    -->
    <setting name="AutomaticUnlockOnSaved" value="false"/>

You can turn this off by editing this option in de web.config ->

<setting name="RequireLockBeforeEditing" value="true"/>

Read more about it here

Good luck!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!