Missing Folders in Umbraco Tree

Posted on August 30, 2019 in umbraco

On this very site, which originally started as a v7 site and has slowly been upgraded to the latest 8.1 release, something weird started happening. Some media folders stopped showing in the media tree left), although they would still show in the media panel (right).

So: the media folders still existed, but they just did not show in trees.

I am pretty sure it worked with 8.0, and stopped working with 8.1. Which is strange, as the original issue seems to target the 7-to-8 upgrade. Anyways. I just wanted to share the cause, and the fix.

The cause is missing rows in the umbracoMediaVersion table for these folders. The fix consists in inserting these missing rows again.

This is exactly what the following SQL does:

insert into umbracoMediaVersion (id, path)
select VersionId, NULL
from (

    select n.id NodeId, n.Text Name, ct.alias Alias, cv.id VersionId, mv.id MvId, mv.path MvPath
    from umbracoNode n
    join umbracoContent c on n.id=c.nodeId
    join cmsContentType ct on c.contentTypeId=ct.nodeId
    join umbracoContentVersion cv on n.id=cv.nodeId
    left outer join umbracoMediaVersion mv on cv.id=mv.id
    where n.nodeObjectType='B796F64C-1F99-4FFB-B886-4BF4BC011A9C'

    and ct.alias='Folder' -- only folders
    and mv.id is null -- that dont have the required row
) x

Note that you may want to run the inner query first, just to verify that your database is indeed missing these rows.

There used to be Disqus-powered comments here. They got very little engagement, and I am not a big fan of Disqus. So, comments are gone. If you want to discuss this article, your best bet is to ping me on Mastodon.