Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen Breuer 4858 posts 12103 karma points MVP 3x admin c-trib
    Dec 06, 2017 @ 13:53
    Jeroen Breuer
    0

    UmbracoContext.Current.MediaCache.GetById(id) is null after upgrade

    Hello,

    I've upgrade our website from 7.4.3 to 7.7.6. Now the following code always returns null:

    UmbracoContext.Current.MediaCache.GetById(id)
    

    I've rebuild the xml cache and all Examine indexes, but I still get the error.

    Since this is an upgrade I've set the following in umbracoSettings.config:

    <EnablePropertyValueConverters>false</EnablePropertyValueConverters>
    

    Any idea why the code doesn't work anymore?

    Jeroen

  • Dan Diplo 1316 posts 4880 karma points MVP 2x c-trib
    Dec 06, 2017 @ 14:19
    Dan Diplo
    0

    Hi Jeroen,

    Hmmm, I've got a few sites upgraded to 7.7.6 and the above works for me, though I do leave EnablePropertyValueConverters as true (and have Umbraco Core Property Value Converters still installed).

    Have you tried setting it to true?

    Also, have you tried rebuilding the internal Examine cache and maybe an app restart?

  • Jeroen Breuer 4858 posts 12103 karma points MVP 3x admin c-trib
    Dec 06, 2017 @ 14:27
    Jeroen Breuer
    0

    We already have some custom property value converters and those will probably break when the default 7.6 ones are enabled.

    Already tried rebuilding the internal Examine cache and an app restart.

    Jeroen

  • Dan Diplo 1316 posts 4880 karma points MVP 2x c-trib
    Dec 06, 2017 @ 15:28
    Dan Diplo
    0

    What is Id that you are passing? An integer or is it an umb://media/ UDI? If the latter you'll need to write converters that deal with these, I guess..

  • Jeroen Breuer 4858 posts 12103 karma points MVP 3x admin c-trib
    Dec 13, 2017 @ 10:46
    Jeroen Breuer
    100

    The problem was the media item was in the recycle bin. Maybe that just worked on Umbraco 7.4, but in Umbraco 7.7 it returns null for media items. Added a null check and now everything works again.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft