What does “Enable Improved Caching of Org Schema” actually do?

This Critical Update sounds like a welcome change, but it’s not terribly specific. What does this Critical Update actually entail? Will we still be able to sniff hidden object types using Id.getSObjectType()? Will this somehow make it impossible to leak versioned API fields (e.g. LastViewedDate to a < 28.0 class)? This sounds like a great new feature if it eliminates bugs, but the wording seems a bit vague.

Answer

There’s been a family of long-standing issues with edge cases in how the platform handles caching schema describe information under the covers. As Daniel mentioned, there are KIs that have gone unfixed where issues like initializing the describe for say, Account, at an old API version and then trying to access it with a newer one would (incorrectly) omit fields added between the old and new version (LastReferencedDate/LastViewedDate being a popular one that was impacted).

There are a number of other other ways this can manifest – if you’ve ever seen the ConferenceNumber type in your global describe? That’s another category of issue where an internal-only SObject was accidentally made accessible through a describe being cached longer than it should have been. The mentioned EmailTemp type isn’t impacted by this type of caching issue, it more simply just lacks the check the prevents it from being org visible (but it is never API editable, so you can’t do anything all that interesting with it anyways) – that’s a wholly different type of issue that this CRUC doesn’t change.

The Apex team did work for Spring ’19 to refactor some of this caching, but if you have code/customizations that rely on this incorrect behavior this change would be considered breaking (despite bringing it in line with documented behavior). Rather than surprise you with this, we put it behind a critical update to allow testing and reporting any potential issues before it’s mandatory.

Really, unless you have some sort of downright insane hack this shouldn’t break anything for you – and if you do have that kind of hack it’s likely not working consistently anyways. With that said, this is also something Hammer testing is poor at caching due to the particulars of the schema caching it runs with, so we particularly felt the need to be safe rather than sorry here without that safety net providing as much assurance as it normally does.

If you ever had support recommend creating a class with a name starting with “AAAA_” to ensure it’s loaded first when compiling? This fixes you.

The wording is a bit vague, since trying to explain the intricacies of our schema definition and caching system is quite arcane, and some gymnastics are required to be able to even describe the type of issues this fixes, particularly to customers who aren’t veteran Apex developers.

If you turn this on and see issues (other than bugs being fixed), we’d love to know more.

Attribution
Source : Link , Question Author : sfdcfox , Answer Author : ca_peterson

Leave a Comment