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] Apply NullAdapter as Null Object#40780

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
derrabus merged 1 commit intosymfony:4.4fromroukmoute:ticket_40753
Apr 12, 2021
Merged

[Cache] Apply NullAdapter as Null Object#40780

derrabus merged 1 commit intosymfony:4.4fromroukmoute:ticket_40753
Apr 12, 2021

Conversation

@roukmoute
Copy link
Contributor

@roukmouteroukmoute commentedApr 12, 2021
edited
Loading

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#40753
LicenseMIT

There is a problem with the NullAdapter if I have to add an expression to work:

$adapter =newNullAdapter();$item =newCacheItem();$item->set('FooBar');if (!$adapter->save($item) && !($adapterinstanceof NullAdapter)) {thrownewException('Uoh oh');}

So the goal here is to modify the methods that are causing a problem to behave as a Null Object.

@carsonbotcarsonbot added this to the4.4 milestoneApr 12, 2021
@carsonbotcarsonbot changed the titleApply NullAdapter as Null Object[Cache] Apply NullAdapter as Null ObjectApr 12, 2021
@derrabus
Copy link
Member

While I do prefer the proposed behavior, I'm unsure if we should simply change it in a bugfix release. Chances are that there are applications out there that rely on the current behavior.

The current behavior is not completely unreasonable either: The cache never persists the passed value, which is whatfalse indicates. My preference would be to leave the adapter untouched on 4.4 and rather make the return value configurable on 5.x.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedApr 12, 2021
edited
Loading

On my side, I think this is a really bug fix. The cache basically says: "true, I saved that item", then it expired it immediately, as it is allowed to do. No implementation should rely on the precise behavior ofNullAdapter anyway - and making this configurable would only increase complexity IMHO.

ro0NL reacted with thumbs up emoji

@roukmoute
Copy link
ContributorAuthor

roukmoute commentedApr 12, 2021
edited
Loading

The cache never persists the passed value, which is whatfalse indicates

If I followPSR-6,false on the methodsave() indicates an error not it was not persisted.

@ro0NL
Copy link
Contributor

No implementation should rely on the precise behavior of NullAdapter anyway

yet here we are :)

it expired it immediately

works for me 👍

@stof
Copy link
Member

No implementation should rely on the precise behavior of NullAdapter anyway

yet here we are :)

the change here is precisely about enabling that, by making sure that NullAdapter does not report an error for its expected behavior.

@derrabus
Copy link
Member

If I followPSR-6,false on the methodsave() indicates an error not it was not persisted.

true indicates that the items was persisted successfully,false indicates an error. Neither fully applies here, so we have to pick one. And I fully agree thattrue feels more correct, given Nicolas' explanation:

then it expired it immediately, as it is allowed to do

Then again, that does not render the current behavior inherently wrong. And we're talking about changing the existing behavior in a bug fix.

@stof
Copy link
Member

@derrabus the current code reports NullAdapter as always having errors when trying to save, which then forces you to do a special case for NullAdapter in any code wanting to report failures loudly, because not persisting the value in NullAdapter is not a failure. It is the expected behavior of the adapter to always miss the cache. See the PR description for such a code.
So to me, this indeed qualifies as a bugfix.

nicolas-grekas and derrabus reacted with thumbs up emoji

Copy link
Member

@derrabusderrabus left a comment

Choose a reason for hiding this comment

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

All right. 🙂

@derrabus
Copy link
Member

Thank you@roukmoute.

@derrabusderrabus merged commit8c43fac intosymfony:4.4Apr 12, 2021
@roukmouteroukmoute deleted the ticket_40753 branchApril 12, 2021 14:27
This was referencedMay 1, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@stofstofstof approved these changes

@derrabusderrabusderrabus approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

6 participants

@roukmoute@derrabus@nicolas-grekas@ro0NL@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp