-
Notifications
You must be signed in to change notification settings - Fork 30
Prevent colliding internal cache ids based on adapter #42
base: master
Are you sure you want to change the base?
Prevent colliding internal cache ids based on adapter #42
Conversation
`json_encode($this->getAdapter())` would always return an empty object for `\Zend\Paginator\Adapter\DbSelect` adapters (i.e. `{}`). By performing `print_r` on the adapter we can get the current state which, in the case of `DbSelect`, includes an sql object containing table name, join details, etc. This will prevent collisions introduced in 2.8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the comment below, we also need unit tests for this change, to demonstrate it actually works.
Thanks!
@@ -865,7 +865,7 @@ protected function _getCacheInternalId() | |||
// @codingStandardsIgnoreEnd | |||
return md5( | |||
get_class($this->getAdapter()) | |||
. json_encode($this->getAdapter()) | |||
. hash('sha512', print_r($this->getAdapter(), true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't spl_object_hash($this->getAdapter())
make more sense here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weierophinney
See your own comment: #41 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spl_object_hash
has been used in the past: 54f4f4c#diff-b7dae88f55a82631386bada74d3d1e9fL863
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay, that makes sense again. (I'm getting old and can't remember this stuff!)
Still need unit tests, though!
This repository has been closed and moved to laminas/laminas-paginator; a new issue has been opened at laminas/laminas-paginator#2. |
This repository has been moved to laminas/laminas-paginator. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
Resolves #41
json_encode($this->getAdapter())
would always return an empty object for\Zend\Paginator\Adapter\DbSelect
adapters (i.e.{}
). By performingprint_r
on the adapter we can get the current state which, in the case ofDbSelect
, includes an sql object containing table name, join details, where clause, etc.This change will prevent collisions between adapters that do not have any public properties and/or values.