2

Closed

1.8.1 Content Creates Fragment Draft if Publish Fails

description

Repro:
  1. Go to Dashboard and create a new page
  2. Leave Title empty (a required field) and type anything in body area (optional)
  3. Press Publish which will return an Orchard Error that Title is required, unfortunately, this just created a draft (open Content menu in another tab)
  4. Add in the Title to correct the issue and publish. You will now have your correct content item and a draft of your failed publish (they are not connected, which is why I call it a fragment)
Closed Feb 28 at 12:51 AM by BertrandLeRoy
I don't see a draft at step 3 of the repro.

comments

jao28 wrote Jul 23, 2014 at 7:25 PM

Here is a fix:

Orchard.Core.Contents.Controllers.AdminController.cs --> CreatePOST method:
if (!ModelState.IsValid) {
    _transactionManager.Cancel();
    // EMS CHANGE - start
    return RedirectToAction("Edit", new { id = contentItem.Id });
    //return View(model);
    // EMS CHANGE - end
}
So instead of returning the model, the user is redirected to edit mode for the content item which was saved as a draft.

If this is deemed risky that the content item might not have recorded everything on screen (have not experienced that) then the draft content item could be deleted and the View / model could be returned (as it is now). This seems riskier to me (I avoid deletes) but could see how that could work also.

jao28 wrote Oct 3, 2014 at 1:14 PM

Please also be aware that there is an identical issue with Widget Layers: https://orchard.codeplex.com/workitem/20987

As mentioned there, the actual issue might be the _transactionManager.Cancel() method.