0

我在以编程方式保存内容时遇到问题,我单击电子邮件消息上的链接并被带到该站点,在这种情况下,CMS 已更新。但是,如果我再次单击该链接,则会收到以下错误:

无法保存非当前版本

"   at Umbraco.Core.Persistence.Repositories.Implement.DocumentRepository.PersistUpdatedItem(IContent entity)\r\n   
at Umbraco.Core.Cache.DefaultRepositoryCachePolicy`2.Update(TEntity entity, Action`1 persistUpdated)\r\n   
at Umbraco.Core.Persistence.Repositories.Implement.RepositoryBase`2.Save(TEntity entity)\r\n   
at Umbraco.Core.Services.Implement.ContentService.<>c__DisplayClass57_0.<CommitDocumentChangesInternal>g__SaveDocument|2(IContent c)\r\n   
at Umbraco.Core.Services.Implement.ContentService.CommitDocumentChangesInternal(IScope scope, IContent content, ContentSavingEventArgs saveEventArgs, 
IReadOnlyCollection`1 allLangs, Int32 userId, Boolean raiseEvents, Boolean branchOne, Boolean branchRoot)\r\n   
at Umbraco.Core.Services.Implement.ContentService.SaveAndPublish(IContent content, String culture, Int32 userId, Boolean raiseEvents)\r\n   
at Web.Controller.Controllers.ContactController.CoachConfirmed(String id) 

代码如下

var contentService = Services.ContentService;
                        var content = contentService.GetById(new Guid(coachDocType));

                        content.SetValue("numberOfTrainees", newNumberOfSpaces);
                        content.SetValue("numberOfTraineesFollowing", newNumberOfSpacesTaken);
                        contentService.SaveAndPublish(content);

在 V7 中,我曾经能够执行 ApplicationContext.Current.Services.ContentService.RePublishAll();,但 V8 似乎不再具有该选项

任何帮助,将不胜感激

乔治

4

1 回答 1

1

似乎这是 Umbraco 中的一个错误,根据https://github.com/umbraco/Umbraco-CMS/issues/2997和修复将在版本 8.3.0 中推出

于 2019-10-01T11:04:47.160 回答