Skip to content

Conversation

@mboelsterli
Copy link
Contributor

The function must be static or the callable needs the object instead of class name.

@carsonbot carsonbot changed the title Wrong callable in async cache computation example Wrong callable in async cache computation example Nov 21, 2025
@nicolas-grekas
Copy link
Member

I suppose the issue is also on 6.4?
It'd go the other way: show how to make this work with a service.
This means using $this in the callback, and also ensure that the container.reversible tag is set on the class. With an AutoconfigureTag attribute?

@mboelsterli
Copy link
Contributor Author

Yes, the issue is also on 6.4.

I've got it working (locally) with a service but this is not working in the dev environment, because of the TraceableAdapter, which wraps the callback in a closure, which is not reversible: https://github.com/symfony/cache/blob/8095968c141288581c6a4dd84ddaeb7920118d22/Adapter/TraceableAdapter.php#L54

If this is a known behave, this should be mentioned in the docs.

@mboelsterli mboelsterli marked this pull request as draft November 24, 2025 12:10
@mboelsterli mboelsterli deleted the mboelsterli-patch-1 branch November 24, 2025 12:24
javiereguiluz added a commit that referenced this pull request Nov 25, 2025
…e (mboelsterli)

This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[Cache] Wrong callable in async cache computation example

Already mentioned in #21587, but now with fix in 6.4 Branch with a reversible service.

I've noticed the fix for closures in early-expiration callbacks: symfony/symfony#62398 in 6.4 and 7.4 (RC2) which fixed my issue in the dev environment: #21587 (comment)

Commits
-------

dcd2a12 [Cache] Wrong callable in async cache computation example
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.

3 participants