platform icon indicating copy to clipboard operation
platform copied to clipboard

Query hints are not being applied after "oro_datagrid.orm_datasource.result.before" event

Open hvanoch opened this issue 5 years ago • 0 comments

Summary
Query hints are applied before the "oro_datagrid.orm_datasource.result.before" is being called. (see src/Oro/Bundle/DataGridBundle/Datasource/Orm/OrmDatasource.php) That way if we add other stuff like the OrmDatasourceAclListener, which adds query hints for applying ACL rules, the hints are not rewalked again.

If this as expected? We override the OrmDatasourceAclListener to apply more strict rules based on custom datagrid options. But since the query hints are resolved before the dispatch of the event, they are never applied. This how it is now.

        $query = $this->qb->getQuery();
        $this->queryHintResolver->resolveHints($query, $this->queryHints ?? []);

        $this->eventDispatcher->dispatch(
            OrmResultBefore::NAME,
            new OrmResultBefore($this->datagrid, $query)
        );

        $rows = $this->queryExecutor->execute($this->datagrid, $query);

How I believe it should be:

        $query = $this->qb->getQuery();

        $this->eventDispatcher->dispatch(
            OrmResultBefore::NAME,
            new OrmResultBefore($this->datagrid, $query)
        );

        $this->queryHintResolver->resolveHints($query, $this->queryHints ?? []);

        $rows = $this->queryExecutor->execute($this->datagrid, $query);

Steps to reproduce

  1. Create a ORMResultBeforeListener which applies a walker, like the \Oro\Bundle\SecurityBundle\ORM\Walker\AclHelper
  2. Load the datagrid.

Actual Result The ACLs did not apply

Expected Result
ACLs being applied

Details about your environment

  • OroPlatform version: 4.1.1
  • PHP version: 7.3
  • Database (MySQL, PostgreSQL) version MySQL

hvanoch avatar May 22 '20 12:05 hvanoch