[9.x] Ignore empty redis username string in PhpRedisConnector#41773
Conversation
|
Thanks! |
PhpRedisConnectorPhpRedisConnector
|
@seanmtaylor did this fix the issue for you? I just upgraded to v9.7.0 which appears to have this fix but I'm still getting a NOAUTH error on Heroku. Dropping back to 9.5.1 where this issue wasn't present. |
|
If it's worth noting - I have 2 Redis instances connected to my Laravel app on Heroku. One has no username like above, and the other has the username However, it worked fine on 9.5.1 and not beyond. Edit: for anyone else who runs across this - Heroku removed the |
Yeah it has sorted it for me @dwightwatson |
A username option was added to the
PhpRedisConnectorin #41683.However, some services, such as Heroku, produce a
REDIS_URLconnection string that has an empty username part.This is causing the following exception:
So given the following
REDIS_URLformat:The following url string, with a blank username, will thrown an error.
Solution
I have added an extra check to ensure that the provided username isn't an empty string before attempting to use it.
Considerations
I have used a
$config['username'] !== ''check rather than! empty($config['username'])in the small off chance that the username value is falsey (eg0).You might just say why not update the
REDIS_URLand replace the empty username part withnull.That's possible, but the issue is services such as Heroku will generate these
REDIS_*variables at any time, such as when upgrading the redis instance, so it would need to be manually changed each time the credentials were generated.Tests
Sorry, I couldn't see any existing tests for this class so wasn't quite sure where to begin.
Feel free to point me in the right direction if a test is required for this.