Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Cache] Handle unserialize() failures gracefully#19567

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedAug 8, 2016
edited
Loading

QA
Branch?3.1
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

This makes fetching cached items more resilient:__PHP_Incomplete_Class "objects" and other errors triggered by unserialize should be turned to cache misses.

GuilhemN reacted with thumbs up emoji
$isHit =false;
}
}catch (\Exception$e) {
CacheItem::log($this->logger,'Failed to unserialize key "{key}"',array('key' =>$key,'exception' =>$e));
Copy link
Contributor

Choose a reason for hiding this comment

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

It should not happen as this adapter is not cross requests (so something not unserializable won't be cached as it is not serializable as well).
If you want to keep this anyway then i guess you should useparent::unserialize below ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok got it it might break in case of a custom unserializer.
At least usingparent::unserialize would allow you to remove the case managingfalse.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

There is no parent here, and calling the same implementation would call ini_set twice for something that can't happen because as you said, this is not cross reqs

Copy link
Contributor

@GuilhemNGuilhemNAug 9, 2016
edited
Loading

Choose a reason for hiding this comment

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

You're right sorry, i should definitely stop reviewing on my phone...

@nicolas-grekasnicolas-grekasforce-pushed thecache-fix-throwing-generator branch from448de93 to5a8dbbeCompareAugust 9, 2016 20:31

yield$key =>$f($key,$value,$isHit);
}
}catch (\Exception$e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be moved inside the foreach to fetch as many values as possible ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

right, done: try/catch moved inside the foreach

@GuilhemN
Copy link
Contributor

LGTM 👍

@nicolas-grekasnicolas-grekasforce-pushed thecache-fix-throwing-generator branch 2 times, most recently from20184d0 to69cfa83CompareAugust 10, 2016 07:15
@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commit47db638 intosymfony:3.1Aug 13, 2016
fabpot added a commit that referenced this pull requestAug 13, 2016
…grekas)This PR was merged into the 3.1 branch.Discussion----------[Cache] Handle unserialize() failures gracefully| Q             | A| ------------- | ---| Branch?       | 3.1| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -This makes fetching cached items more resilient: `__PHP_Incomplete_Class` "objects" and other errors triggered by unserialize should be turned to cache misses.Commits-------47db638 [Cache] Handle unserialize() failures gracefully
@nicolas-grekasnicolas-grekas deleted the cache-fix-throwing-generator branchAugust 18, 2016 20:02
@fabpotfabpot mentioned this pull requestSep 3, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@nicolas-grekas@GuilhemN@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp