The CRUD permission check for Security Review has been imposed recently, though I'm clear on the DML statement and Create/Update/Delete permissions I need to check for in my code, but I'm not clear how to proceed with SOQL queries in my code.
Do I need to verify Object read permissions for Objects & all fields in query before executing SOQL?
Consider following code:
public with sharing class MySetupController {
public MySetupController() {
system.debug('@ Read Permission Check: '+Schema.myns__Global_Settings__c.getSObjectType().getDescribe().isAccessible());
myns__Global_Settings__c[] f = [Select Id From myns__Global_Settings__c limit 1];
util.logInfo('f: '+f);
initSettingsRequired = (f.size() == 0);
}
}
In this code, the Schema.myns__Global_Settings__c.getSObjectType().getDescribe().isAccessible()
is FALSE
but still I am able to execute the query just below that line without any error. I don't understand why it didn't threw error and allowed reading the object, I even get 1 record in the next debug statement for that query.
Please note that the current User's profile does not have any CRUD permission on this object myns__Global_Settings__c. I've turned all Object Permission Checkboxes Off in User's Profile.