LPS-45001 Modifying permission check query

Hey Ray,

This pull is coming from support. I'm sending this to you as it's entirely related to inline permission checking fw. 

You can see more details here:
https://github.com/sergiogonzalez/liferay-portal/pull/1340

Thx!