Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cache] Hash cache key on save #23763

Merged
merged 1 commit into from Aug 7, 2017
Merged

[Cache] Hash cache key on save #23763

merged 1 commit into from Aug 7, 2017

Conversation

lstrojny
Copy link
Contributor

@lstrojny lstrojny commented Aug 2, 2017

Q A
Branch? 3.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? ye
Fixed tickets n.A.
License MIT
Doc PR n.A.

Cache keys are not hashed right now in adapters extending from AbstractAdapter. This PR fixes this. I am not familiar enough with the cache test suite so I don't know where to add an regression test.

@lstrojny lstrojny changed the title Hash cache key on save [CACHE] Hash cache key on save Aug 2, 2017
@lstrojny lstrojny changed the title [CACHE] Hash cache key on save [Cache] Hash cache key on save Aug 2, 2017
@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Aug 2, 2017
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Aug 2, 2017

you can add a test case in AdapterTestCase I guess

@lstrojny
Copy link
Contributor Author

lstrojny commented Aug 2, 2017

@nicolas-grekas added a case to the MemcachedAdapterTest

@nicolas-grekas
Copy link
Member

can we move it to the FilesystemAdapterTest ? I think it may have the issue also, and this would allow more people to actually run the test

$byLifetime = array();
$now = time();
$expiredIds = array();

foreach ($deferred as $key => $item) {
$id = $getId(is_int($key) ? (string) $key : $key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call this inline (no need for the $id intermediary variable)
and I would move the cast to string inside the closure.
also, now need of the is_int check, we should unconditionally cast to string instead

@nicolas-grekas
Copy link
Member

wait, it really needs to be in AdapterTestCase, all of them need to run that test

@nicolas-grekas
Copy link
Member

it should also be in Simple\CacheTestCase, just for parity

@nicolas-grekas
Copy link
Member

Could even be part of https://github.com/php-cache/integration-tests, with even longer keys.
/cc @Nyholm

@nicolas-grekas
Copy link
Member

Thank you @lstrojny.

@nicolas-grekas nicolas-grekas merged commit 94b1b12 into symfony:3.3 Aug 7, 2017
nicolas-grekas added a commit that referenced this pull request Aug 7, 2017
This PR was merged into the 3.3 branch.

Discussion
----------

[Cache] Hash cache key on save

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | ye
| Fixed tickets | n.A.
| License       | MIT
| Doc PR        | n.A.

Cache keys are not hashed right now in adapters extending from `AbstractAdapter`. This PR fixes this. I am not familiar enough with the cache test suite so I don't know where to add an regression test.

Commits
-------

94b1b12 Hash cache keys on save
@fabpot fabpot mentioned this pull request Aug 28, 2017
@lstrojny lstrojny deleted the cache-key-hash-on-save branch August 28, 2017 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants