DDC-3198: [GH-1075] Fixed query cache id generation: added platform to hash #3960

Closed
opened 2026-01-22 14:32:25 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Jun 27, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of vilartoni:

Url: https://github.com/doctrine/doctrine2/pull/1075

Message:

There's an issue with the query cache id generation in Doctrine\ORM\Query::_getQueryCacheId().

If you happen to use different connections to different platforms on the same project and you're using the query cache, you will get an exception the moment you try to execute a query which SQL is different depending on the platform and it has been previously cached for the other platform, as they will share the same cache id.

In order to reproduce the bug it is sufficient with using the Doctrine Paginator in a query:

$query = $queryBuilder->setFirstResult(0)
    ->setMaxResults(50)
    ->getQuery()
    ->getResult();

If we run the query for the first time with an empty cache in an Oracle connection and later on we try to run the same query in a MySQL connection, we get the following exception:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ROWNUM' in 'where clause'

As it's trying to execute the SQL for Oracle in the MySQL connection due to the same cache id.

This issue can be easily fixed just by taking the platform type into account in the cache id generation.

Originally created by @doctrinebot on GitHub (Jun 27, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of vilartoni: Url: https://github.com/doctrine/doctrine2/pull/1075 Message: There's an issue with the query cache id generation in `Doctrine\ORM\Query::_getQueryCacheId()`. If you happen to use different connections to different platforms on the same project and you're using the query cache, you will get an exception the moment you try to execute a query which SQL is different depending on the platform and it has been previously cached for the other platform, as they will share the same cache id. In order to reproduce the bug it is sufficient with using the Doctrine Paginator in a query: ``` $query = $queryBuilder->setFirstResult(0) ->setMaxResults(50) ->getQuery() ->getResult(); ``` If we run the query for the first time with an empty cache in an Oracle connection and later on we try to run the same query in a MySQL connection, we get the following exception: ``` SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ROWNUM' in 'where clause' ``` As it's trying to execute the SQL for Oracle in the MySQL connection due to the same cache id. This issue can be easily fixed just by taking the platform type into account in the cache id generation.
admin added the Bug label 2026-01-22 14:32:25 +01:00
admin closed this issue 2026-01-22 14:32:25 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jun 27, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1075] was closed:
https://github.com/doctrine/doctrine2/pull/1075

@doctrinebot commented on GitHub (Jun 27, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-1075] was closed: https://github.com/doctrine/doctrine2/pull/1075
Author
Owner

@doctrinebot commented on GitHub (Jun 27, 2014):

Comment created by @ocramius:

Merged: c370426792

@doctrinebot commented on GitHub (Jun 27, 2014): Comment created by @ocramius: Merged: https://github.com/doctrine/doctrine2/commit/c370426792edda8290843e601e9f95d86a7e873f
Author
Owner

@doctrinebot commented on GitHub (Jun 27, 2014):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jun 27, 2014): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3960