Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
f202e76b
Unverified
Commit
f202e76b
authored
Apr 17, 2019
by
Jonathan H. Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maintain platform parameter in connection params but remove it before
using params in query cache key generation.
parent
3a0a1d10
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
+55
-2
Connection.php
lib/Doctrine/DBAL/Connection.php
+4
-2
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+51
-0
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
f202e76b
...
...
@@ -200,7 +200,6 @@ class Connection implements DriverConnection
}
$this
->
platform
=
$params
[
'platform'
];
unset
(
$this
->
params
[
'platform'
]);
}
// Create default config and event manager if none given
...
...
@@ -932,7 +931,10 @@ class Connection implements DriverConnection
throw
CacheException
::
noResultDriverConfigured
();
}
[
$cacheKey
,
$realKey
]
=
$qcp
->
generateCacheKeys
(
$query
,
$params
,
$types
,
$this
->
getParams
());
$connectionParams
=
$this
->
getParams
();
unset
(
$connectionParams
[
'platform'
]);
[
$cacheKey
,
$realKey
]
=
$qcp
->
generateCacheKeys
(
$query
,
$params
,
$types
,
$connectionParams
);
// fetch the row pointers entry
$data
=
$resultCache
->
fetch
(
$cacheKey
);
...
...
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
f202e76b
...
...
@@ -880,4 +880,55 @@ class ConnectionTest extends DbalTestCase
$connection
->
getDatabasePlatform
();
}
/**
* @group #3194
*/
public
function
testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys
()
:
void
{
/** @var Driver|MockObject $driver */
$driver
=
$this
->
createMock
(
Driver
::
class
);
/** @var AbstractPlatform|MockObject $platform */
$platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
/** @var QueryCacheProfile|MockObject $queryCacheProfile */
$queryCacheProfile
=
$this
->
createMock
(
QueryCacheProfile
::
class
);
/** @var Cache|MockObject $resultCacheDriver */
$resultCacheDriver
=
$this
->
createMock
(
Cache
::
class
);
$queryCacheProfile
->
expects
(
$this
->
any
())
->
method
(
'getResultCacheDriver'
)
->
will
(
$this
->
returnValue
(
$resultCacheDriver
));
$resultCacheDriver
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'fetch'
)
->
with
(
'cacheKey'
)
->
will
(
$this
->
returnValue
([
'realKey'
=>
[]]));
$query
=
'SELECT 1'
;
$params
=
[
'dbname'
=>
'foo'
,
'platform'
=>
$platform
,
];
$paramsWithoutPlatform
=
$params
;
unset
(
$paramsWithoutPlatform
[
'platform'
]);
$queryCacheProfile
->
expects
(
$this
->
once
())
->
method
(
'generateCacheKeys'
)
->
with
(
$query
,
[],
[],
$paramsWithoutPlatform
)
->
will
(
$this
->
returnValue
([
'cacheKey'
,
'realKey'
]));
$connection
=
new
Connection
(
$params
,
$driver
);
self
::
assertSame
(
$params
,
$connection
->
getParams
());
$connection
->
executeCacheQuery
(
$query
,
[],
[],
$queryCacheProfile
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment