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

fix(caching): Avoid checking existence before fetching #38591

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

ChristophWurst
Copy link
Member

Summary

Following

* @deprecated 9.1.0 Directly read from GET to prevent race conditions
.

The cache might expire between checking for key existence and fetching the value. In this rare case the code continues with a null value when it doesn't expect one.

Checklist

Copy link
Member

@pulsejet pulsejet left a comment

Choose a reason for hiding this comment

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

The doc here should be updated to say that null must be returned if the key doesn't exist. Implementions might end up returning something else, e.g. false

/**
* Get a value from the user cache
* @param string $key
* @return mixed
* @since 6.0.0
*/
public function get($key);

The cache might expire between checking for key existence and fetching
the value. In this rare case the code continues with a null value when
it doesn't expect one.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@szaimen szaimen force-pushed the fix/caching/avoid-haskey-get branch from 5d6e7b8 to b8c61b3 Compare June 12, 2023 07:44
@szaimen szaimen enabled auto-merge June 12, 2023 07:44
@szaimen szaimen merged commit 83faba5 into master Jun 12, 2023
@szaimen szaimen deleted the fix/caching/avoid-haskey-get branch June 12, 2023 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

5 participants