Umbraco Fix – No Document exists with Version

Recently I had problems with a site I have created using umbraco. The problem was that for some reason in the version control of the application there were many orphan versions that where visible on the cmsContentVersion table but not on the cmsDocument. You can find those using the query below:

SELECT * FROM cmsContentVersion
WHERE
	cmsContentVersion.VersionId NOT IN (SELECT VersionId FROM cmsDocument) AND
	cmsContentVersion.ContentId IN (SELECT nodeId FROM cmsDocument)

Deleting those record fixed my problem and the problematic nodes where shown again in both the content tree view and edit view in umbraco CMS. To delete those versions in your database use the code below:

DELETE FROM cmsContentVersion
WHERE
	cmsContentVersion.VersionId NOT IN (SELECT VersionId FROM cmsDocument) AND
	cmsContentVersion.ContentId IN (SELECT nodeId FROM cmsDocument)

Comments

20 responses to “Umbraco Fix – No Document exists with Version”

  1. Patrik Avatar
    Patrik

    Thank you for this fix.

  2. eran Avatar

    works like a charm! probably saved me lot of work to find the problem.
    thanks!

  3. Amelie Avatar
    Amelie

    Thank you very much! I was looking for a fix for few hours and yours worked !

  4. Bjørn Fridal Avatar

    I have used this fix several times now. Thanks 🙂

  5. Andy Avatar
    Andy

    Thanks. This got me out of a hole. In my particular case I also had to delete from the cmsPreviewXML table too based on the above query….

    DELETE FROM cmsPreviewXML WHERE versionID IN (
    SELECT VersionId FROM cmsContentVersion
    WHERE
    cmsContentVersion.VersionId NOT IN (SELECT VersionId FROM cmsDocument) AND
    cmsContentVersion.ContentId IN (SELECT nodeId FROM cmsDocument))

    Not entirely sure why the node got messed up.

  6. hsj Avatar
    hsj

    But what is the problem, why does this happen, I’m not confident deleting random records from my Umbraco when this problem arises?

  7. Suranga Avatar

    Thanks, this fixed my issue today. Cheers.

  8. dr memals Avatar
    dr memals

    @hsj I am with you, we have a number of Umbraco environments and only one is exhibiting this issue.
    Need a better understanding what the problem is and what causes it then get the devs to fix it.
    Running delete on a live database without understanding the true impact is not acceptable.

    1. spyriadi Avatar
      spyriadi

      Umbraco keeps track of all the changes made on every node in the content so that it has history and it is possible to revert to a previous version. So every time you save a node from the content or publish it does not change the old record what it does is create a new one with all the data again. Now in case something goes wrong while saving or publishing there are some cases that the new version is created in the database but the coresponding data has not been saved. This leaves you with this error since when umbraco tries to retrieve the latest version of the document that record does not exist!

  9. Amhed Avatar
    Amhed

    Awesome, thanks!

  10. Sobin Avatar
    Sobin

    Thanks.. You saved my time 🙂

  11. Stefan Beyer Avatar

    The issue showed up in some of my environments after calling PublishWithSubs(…) in code.

    PublishWithChildrenWithResult(…) does the trick.

    Seems to me that the api is a big mess 🙁

  12. Stefan Beyer Avatar

    PS: Thank you for the hint, saved me a lot of time! 😉

  13. Doug Ludlow Avatar

    Worked like a charm!

  14. Thomas Egebrand Gram Avatar

    Thanks a lot, worked like a charm! 🙂

    Beware, for this to work in MySQL, use all-uppercase:

    SELECT * FROM CMSCONTENTVERSION
    WHERE
    CMSCONTENTVERSION.VERSIONID NOT IN (SELECT VERSIONID FROM CMSDOCUMENT) AND
    CMSCONTENTVERSION.CONTENTID IN (SELECT NODEID FROM CMSDOCUMENT)

  15. Jae Avatar
    Jae

    Perfect, thank you!

  16. ugg outlet Avatar

    Hiya! This is the third time visiting now and I just wanted to say I truley fancy looking at your website. I have decided to bookmark it at stumbleupon.com with your title: and your Web address: . I hope this is all right with you, I’m making an attempt to give your excellent blog a bit more exposure. Be back shortly.

    1. spyriadi Avatar
      spyriadi

      Of course its OK! Thank you… 🙂

  17. spud bahongus Avatar
    spud bahongus

    spyriadi,

    Your post saved me hours in a jam on a large production site. Thank you very much. In my case, there was one problematic top-level node that appeared unpublished (i.e. the starburst icon showed over a top level date folder) I looked up all activity on that node, using this query:

    select COUNT(*) as NumberOfEvents, logHeader, userId from umbracoLog
    join umbracoUser UU on
    umbracoLog.userId = UU.id
    where NodeId = ‘15293’
    group by userId, logHeader order by NumberOfEvents desc

    Note that one of the users had 463 publishes on a date folder node. Not sure why someone would keep trying to publish a date folder over and over again, but after reading your comment to drmemal above, I do see a connection. Thanks!

  18. Jamez Jay Avatar

    Awesome! I just had the same issue and you saved me a bunch of time. Thanks for sharing your wisdom!

Leave a Reply

Your email address will not be published. Required fields are marked *