-
Notifications
You must be signed in to change notification settings - Fork 325
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
2.1.5 (lazy loading) somehow breaks set method on session client #442
Comments
Talking about it with @Ocramius here: https://twitter.com/dkarlovi/status/1020271285320941568 |
Please also show the generated code for the proxy. |
You mean this? |
So, as noted:
It should be one of, they're both included for some reason. |
Yep, exactly that. And holy crap this class has an atrocious API: just how many responsibilities are crammed together here?! Besides that, as you can see, To keep in mind when going further here:
|
Btw, this is neither a bug in ProxyManager nor in this bundle: you will need to either fix this in the extension, or provide a userland shim that can be reflected. |
Alright, thanks. I guess we need to open an issue with Phpredis. |
Thanks for the quick feedback guys. Highly appreciated! |
Yep, phpredis is a mess, it's essentially just all Redis commands thrown together in a big bucket class. Considering that's how Redis itself works it's not even unreasonable but it makes wrapping hell. Marking this issue as a not-our-problem-but-we-need-to-keep-it-in-mind issue. |
Opened the issue: phpredis/phpredis#1374 |
…edis extension - issue - snc/SncRedisBundle#442
…edis extension - issue - snc/SncRedisBundle#442
…edis extension - issue - snc/SncRedisBundle#442
…edis extension - issue - snc/SncRedisBundle#442
…edis extension - issue - snc/SncRedisBundle#442
…edis extension - issue - snc/SncRedisBundle#442
…edis extension - issue - snc/SncRedisBundle#442
@dkarlovi how do you propose we handle compatibility on this until and after phpredis has released a fix? Should/could we just prohibit the lazy loading in "broken" phpredis versions? |
As mentioned above: provide a userland class that has the complete signature |
@Ocramius any pointers how we would provide such a class from a bundle? |
By writing it? O_o |
Once reflection data is correct we can generate it during container compilation from that, which is actually a good idea anyway because it's also the only way I see to re-enable the profiler wrappers. |
I suggest doing it at least for a new minor |
@lashae if using lazy services not until you are running the new phpredis version which may be released later tonight. |
Pushed a toy to test reflection against released and |
@Ocramius this is my first time using both ProxyManager and BetterReflection so it's probably broken in more than one way, but it seems there's issues with either BetterReflection or ProxyManager with certain methods. Example:
|
Most likely typical PHP extension fuckery. In PHP extensions, it is possible to have an optional parameter that also considers the missing parameter Example: function foo(array $bar = []){} In PHP core, you can decide that The other possibility is that the method is completely mis-documented, and you will need to experiment with combinations of allowed parameters. |
Issue fixed with Phpredis 4.1.1. The bundle should still provide a stub for users who don't have this version installed, though. |
I can confirm this fully works with Phpredis 4.1.1 within my app. If you're using Alpine, you can already find it packaged for Edge. |
Thank you all! Amazing work :-) |
Nice, I was wondering why the application cashes when updated a minor version of this bundle 😄 So maybe having the option to disable the lazy loading of the client via the configuration would fix that regardless the phpredis version? |
@ondrejfuhrer Which issue are you talking about exactly? This one or the cache warmup issue with redis server available? The lazyness was introduced because phpredis object creation was creating a connection to Redis server even if you don't really need it. For example when you warm up the cache. This was happening only with some symfony configuration. We could always add an opt-out option for lazyness indeed, but not sure it worth it. I quickly checked Symfony codebase for the redis cache adapter and it looks like the lazyness is implemented by using Cheers. |
It's not forced as lazy, we're just supporting a feature in Symfony now we should have been doing before. We were just not aware of the bug in phpredis < 4.1.1 we uncovered with it, hence why the "breaking change" occurred in a minor. |
@B-Galati @curry684 If that would be written in a way: $lazyClient = $container->getParameter('snc_redis.phpredis_client.lazy') ?? true;
...
$phpredisDef->setLazy($lazyClient); Then even for people who cannot for whatever reason upgrade Phpredis fast enough, as a tradeoff you can disable the lazy loading and work with the latest bundle version. I have confirmed myself that changing that line is indeed "fixing" the issue wit not passed arguments to the |
@ondrejfuhrer Thank you I think we could do two things:
|
@B-Galati Also one thing to mention -> there is also inconsistency in loading the clients based on what type you use (I would personally prefer consistency there). What I mean is that right now the Phpredis client is loaded as lazy and Predis client is not. So it would also make sense from consistency perspective to have both affected by that option. |
@ondrejfuhrer No I don't think so because Predis client is lazy by default: it does not try to connect to redis unless something is asked. |
Here's some additional intel on the matter of the lazy loading problem: Phpredis was recently upped to public function multi($mode = null) whereas the real default value for This means when the service is lazy loaded, and we use the method without arguments, the actual method is called like I understand we can create our own stub and (re)introduce default values in a user defined class which would result in a perfect reflection info and in turn a 1:1 proxy class. But, there are many versions of Phpredis to support. How to handle many cases? Whose responsibility would it be to write a correct stub for (every) Phpredis release? I assume there would be a way to have this bundle use the correct stub, based on ext-redis version, but this seems like a heavy undertaking with synchronicity on both sides. Further, with older versions of Phpredis (ie. 4.0.2) this particular method did not have any ARGINFO present so based on the reflection information, the optional argument was never forwarded from the proxy class to the real class. One could literally call the method like This is a general issue with proxies for internal classes, maybe Symfony should not create proxies for them at all? Even if everything is done right on the side of Phpredis (which is not, but let's assume) - still there is the fact that reflection does not have the ability to get default values for optional arguments of internal methods. This change would render your lazy loading technique futile though. All this said, I think the most immediate solution would be to add a Partially, this is discussed in phpredis/phpredis#1476 too. |
As noted in phpredis/phpredis#1476 (comment), this is fully on |
Setting the default to |
In Symfony, they use a special kind of laziness. I guess it allows to bypass some weird edge cases like we have right now: I would love to use this |
@B-Galati maybe asking @nicolas-grekas directly is best? |
Copy/pasting is fine really. |
Thanks @nicolas-grekas and @dkarlovi! |
I think this has been fixed in #507 |
Hey guys,
the lazy-loading introduced with the latest patch somehow seems to break the
set
method.When calling it, the following error pops up:
although it gets called with 3 parameters (in a controller):
The text was updated successfully, but these errors were encountered: