What does "Enable Improved Caching of Org Schema" actually do?
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.
I'd checked in with Chris Peterson about this, specifically around the concern that I wouldn't be able to use Id.getSObjectType()
. This critical update isn't about that altering that behavior.
Instead it is to fix known issues like Missing dependent object: Field: .LastViewedDate error occurs when Apex class with API version 28.0+ is used in VF with API version 27.0-. As you mentioned, this is where the LastViewedDate field in the describe map from and API V28.0 Apex class caused errors in a Visualforce page on v27.0 or lower that used the Apex class as it's controller.
This knowledge article details the Known Issues that this critical update fixes:
When performing several SOQL queries from different Apex classes, "No such column 'LastViewedDate' on entity " is thrown
Parsing an inline query referring to the User.Account foreign key fails with the "Didn't understand relationship 'Account' in field path..." error
Namespaced aggregate FieldInfos are cached incorrectly on EntityInfoImpl if subscriber org has non namespaced field with similar child relationship name
Missing dependent object: Field: .LastViewedDate error occurs when Apex class with API version 28.0+ is used in VF with API version 27.0
Geo location fields throwing "No such column 'XXX__c' on entity 'XXXX__c' during deployment.
An Internal Server Error Message is displayed when adding a Campaign Sharing rule when "Enable Improved Caching of Org Schema" is turned on.
Improved Caching of Org Schema (Critical Update) - Change event entities added in later API versions are visible in lower version