Multiple ContentItemVersionRecords published for same parent ContentItemRecord

Topics: Core, Troubleshooting
May 22, 2013 at 1:53 AM
I've had an issue where a content item had multiple records in the 'ContentItemVersionRecords' table marked as publish. In my case there were two marked as Published.

This was causing a crash in this function in DefaultContentManager.cs on the 'SingleOrDefault()' call.
        public virtual void Publish(ContentItem contentItem) {
            if (contentItem.VersionRecord.Published) {
                return;
            }
            // create a context for the item and it's previous published record
            var previous = contentItem.Record.Versions.SingleOrDefault(x => x.Published);
            var context = new PublishContentContext(contentItem, previous);

            // invoke handlers to acquire state, or at least establish lazy loading callbacks
            Handlers.Invoke(handler => handler.Publishing(context), Logger);

            if (previous != null) {
                previous.Published = false;
            }
            contentItem.VersionRecord.Published = true;

            Handlers.Invoke(handler => handler.Published(context), Logger);
        }
Any ideas what might have caused the database to get into this state?
Developer
May 22, 2013 at 9:59 AM
Do you have an idea how this could happen? I noticed a similar thing happening a couple of times when editing/publishing multiple content items at once in parallel AJAX requests. This happened on production server and I was not able to ever repro it on my local. What is your scenario?

This smells like a bug. Please create a ticket so we'll have more eyes looking at it.
May 22, 2013 at 11:31 PM
This was on production... but other than that I don't have any helpful info. It was our client who happened on the issue so I have no idea how to reproduce unfortunately.

Issue made: https://orchard.codeplex.com/workitem/19738