public IPublishedContent GetRootMedia(string mediaFolder)
{
var mediaRoots = _umbHelper.TypedMediaAtRoot();
return mediaRoots.FirstOrDefault(f => f.Name == mediaFolder);
}
mediaRoots it returns empty collection despite there are a few media folders at root. This seems to happen every some time though - not every time or not for every member.
Just a thought, is your Examine InternalIndex populated?
I think there is a caching layer when querying Media that uses the Examine internal index, sometimes if this index is empty or corrupt, you get unpredictable results when querying for media.
Also replying about the index - the internal index is running and the umbraco CMS works fine, so the index is working but for some reason the API does not get the result.
Also I have deleted the external index, the index has been recreated and the issue persists.
TypedMediaAtRoot returns null despite media folders exist
mediaRoots
it returns empty collection despite there are a few media folders at root. This seems to happen every some time though - not every time or not for every member.produces the same (
null
) result.Why would it happen?
Umbraco 7.15.3
Hi nickornotto
Just a thought, is your Examine InternalIndex populated?
I think there is a caching layer when querying Media that uses the Examine internal index, sometimes if this index is empty or corrupt, you get unpredictable results when querying for media.
regards
Marc
Hi Marc, Thanks for replying.
The Internal index is running and there is no sign of it erroring when the media error happens.
Sometimes the error keeps happening for the same members all over again while is not happening for others though.
I can sometimes replicate it in local environment either.
Also replying about the index - the internal index is running and the umbraco CMS works fine, so the index is working but for some reason the API does not get the result.
Also I have deleted the external index, the index has been recreated and the issue persists.
To me it looks like the bug in the API.
is working on a reply...