Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-55291

Error when checking for permissions with many roles assigned

    Details

      Description

      When having more than the configured threshold of roles for a user (including inherited roles), nearly every resource permission check fails with:

      ...
      Caused by: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.SQLGrammarException: could not execute query
      	at com.liferay.portal.dao.orm.hibernate.ExceptionTranslator.translate(ExceptionTranslator.java:30)
      	at com.liferay.portal.dao.orm.hibernate.SQLQueryImpl.uniqueResult(SQLQueryImpl.java:415)
      	at com.liferay.portal.service.persistence.ResourcePermissionFinderImpl.countByC_N_S_P_R_A(ResourcePermissionFinderImpl.java:162)
      ... 144 more
      Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
      	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
      	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      	at org.hibernate.loader.Loader.doList(Loader.java:2545)
      	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
      

      It seems, that the SQL query for countByC_N_S_P_R_A is wrong:

      SELECT
      	COUNT(*) AS COUNT_VALUE
      FROM
      	ResourcePermission
      WHERE
      	(ResourcePermission.companyId = ?) AND
      	(ResourcePermission.name = ?) AND
      	(ResourcePermission.scope = ?) AND
      	(ResourcePermission.primKey = ?) AND
      	(ResourcePermission.roleId = ?) AND
      	(BITAND(CAST_LONG(ResourcePermission.actionIds, ?)) = ?) 
      

      The bracket should move: (BITAND(CAST_LONG(ResourcePermission.actionIds), ?) = ?)

      A workaround is to set permissions.role.resource.permission.query.threshold to some unusual big value.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 27 weeks, 5 days ago

                  Packages

                  Version Package
                  6.1.X EE
                  6.2.4 CE GA5
                  6.2.X EE
                  7.0.0 M5