We have moved to GitHub Issues
Created by Stephan 16 Aug 2016, 13:32:53 Updated by Lee Kelleher 02 Nov 2016, 12:51:38Tags: Unscheduled
Is duplicated by: U4-9006
Relates to: U4-7823
Get non-existing media from media cache: media cache logs one line "Could not retrieve media...". On a site with media pickers, where a good number of picked medias have been deleted, this floods the log. We should only log a warning if the media could not be retrieved from Examine yet exists in the DB - and even though, we should do it once only.
When a media is not found in Examine, we first try to load from DB before logging anything. If it is not in the DB either then all is well and we return. If it ''is'' in the DB then we have an issue and we log a warning stating that the Examine index is probably corrupted.
Actually, we only log after a given (10) number of failures, and we only log once (until the app restarts).
Review: create a page that gets an existing media eg media = Umbraco.TypedMedia(1234) - then clear the Examine index and reload that page more than 10 times => should see 1 log line about it.
Looking good - it's merged!
Note - test needs to be 10 different media items failing, since the result is cached so the miss count will only be increased when requesting a different id (which I've talked to @zpqrtbnk about and it seems like the best way to do the logging).
Seeing this in 7.4.2, in the meantime is there a way to tell what nodes/partials/macros those media calls might be coming from? I'd try to resolve them but since the media folders themselves are of course missing, it's hard to know what node or code is looking for them.
@Eric.Schrepel Not really - there's nothing in the logs telling exactly what requested those specific items - it could also be any kind of custom code running in your site, utilizing the APIs without the request actually coming from a visit to a node.
I guess the only way would be to either load your pages one at a time and see if that triggered anything in the logs and go from there - or create a script that runs through all your items and checks for missing references.
@zpqrtbnk Apologies if I should post this elsewhere, I wasn't sure where was the best place. I have a question about the
So the logic goes...
My question is, if when querying Examine we're checking if the item is trashed, but we're not doing the same when querying the MediaService. Wouldn't this mean that it will always return a trashed media item?
methink you're right and it should read
var media = ApplicationContext.Current.Services.MediaService.GetById(id); if (media == null || media.Trashed) return null; // not found, ok
Correct? Will fix.
@zpqrtbnk Sounds great! Thanks Stephan!
Did you want me to create a separate ticket for this? So there's a reference chain on the tracker/release notes?
sure if you have a min that'd be great
No problem-o, created issue #U4-9137
Backwards Compatible: True
Affected versions: 7.5.0
Due in version: 7.5.1
Sprint: Sprint 40