function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pranavaditya KannojooPranavaditya Kannojoo 

Schema.getGlobalDescribe unexpected behavior in managed package

I have code similar to below

if(Schema.getGlobalDescribe().get('ChatterMessage') == null){
          chatterMessageEnabled = false;
} else {
          chatterMessasgeEnabled = true;
}

In one of the environment we have disabled Private Messaging so that this standard object is not accessible. When I execute above code snippet in developer console, I notice that the chatterMessageEnabled is set to false which is expected. 

However if this similar code is installed as part of managed package in the same environment, notice that chatterMessageEnabled is set to true which is unexpected and causing issues. Can any one help in overcoming this issue? 

Searching on Schema.getGlobalDescribe results that its behavior in managed package is always trickier. 
MaxPowerForceMaxPowerForce
This sounds like a bug.  I have noticed this before and it was resolved by increasing the API version of the class.  What API version is your class? 

Take a look at this issue:

https://success.salesforce.com/issues_view?id=a1p30000000T3iVAAS

Its not exactly the same thing, but it could be similar. 
Pranavaditya KannojooPranavaditya Kannojoo
API version of our class is 28.0

In which API version is this bug resolved?
MaxPowerForceMaxPowerForce
I looked at this a bit and the bug I posted seems unrelated.  The result of that describe call is context dependent for some reason.  Called from a trigger the object is available, called from execute anonymous, it is not.  This is not dependent on API version, nor is it affected by declaring the class with/without sharing.  I would open a Salesforce support case.