platform
platform copied to clipboard
Query hints are not being applied after "oro_datagrid.orm_datasource.result.before" event
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
- Create a ORMResultBeforeListener which applies a walker, like the \Oro\Bundle\SecurityBundle\ORM\Walker\AclHelper
- 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