George Phillipson
George Phillipson

Reputation: 860

Cannot save a non-current version - Umbraco 8

I'm having a problem with saving content programmatically, I click a link on an email message and I'm taken to the site, on this occasion, the CMS is updated. But if I click the link again I get the following error:

Cannot save a non-current version

"   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) 

The code is below

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

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

In V7, I use to be able to do ApplicationContext.Current.Services.ContentService.RePublishAll();, but V8 does not seem to have that option anymore

Any help would be appreciated

George

Upvotes: 0

Views: 796

Answers (1)

George Phillipson
George Phillipson

Reputation: 860

Seems this is a bug in Umbraco, as per https://github.com/umbraco/Umbraco-CMS/issues/2997 and fix will be rolled out in version 8.3.0

Upvotes: 1

Related Questions