Prevent colliding internal cache ids based on adapter#42
Prevent colliding internal cache ids based on adapter#42richard-parnaby-king wants to merge 1 commit into
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
weierophinney
left a comment
There was a problem hiding this comment.
Besides the comment below, we also need unit tests for this change, to demonstrate it actually works.
Thanks!
| return md5( | ||
| get_class($this->getAdapter()) | ||
| . json_encode($this->getAdapter()) | ||
| . hash('sha512', print_r($this->getAdapter(), true)) |
There was a problem hiding this comment.
Wouldn't spl_object_hash($this->getAdapter()) make more sense here?
There was a problem hiding this comment.
spl_object_hash has been used in the past: 54f4f4c#diff-b7dae88f55a82631386bada74d3d1e9fL863
There was a problem hiding this comment.
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\DbSelectadapters (i.e.{}). By performingprint_ron 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.