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] Fix connecting to Redis via a socket file#45281

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
nicolas-grekas merged 1 commit intosymfony:4.4fromalebedev80:bug_fix_a_socket_connection_without_port
Feb 4, 2022
Merged

[Cache] Fix connecting to Redis via a socket file#45281

nicolas-grekas merged 1 commit intosymfony:4.4fromalebedev80:bug_fix_a_socket_connection_without_port
Feb 4, 2022

Conversation

@alebedev80
Copy link
Contributor

@alebedev80alebedev80 commentedFeb 2, 2022
edited by nicolas-grekas
Loading

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets#45277
LicenseMIT
Doc PR

In thecommit was done follow changes in Traits/RedisTrait.php(188)

Old code:

$port = $hosts[0]['port'] ?? null;

New code:

$port = $hosts[0]['port'] ?? 6379;

With DSN "redis:///var/run/redis/redis.sock" raise an error:

Redis connection "redis:///var/run/redis/redis.sock?dbindex=5" failed: php_network_getaddresses: getaddrinfo failed: Name or service not known

Because phpredis doesn't allow socket connections with a port

(new Redis)->connect('/var/run/redis/redis.sock', 6379);

Error

PHP Warning:  Redis::connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /root/test_redis.php on line 5PHP Fatal error:  Uncaught RedisException: php_network_getaddresses: getaddrinfo failed: Name or service not known in /root/test_redis.php:5Stack trace:#0 /root/test_redis.php(5): Redis->connect()#1 {main}  thrown in /root/test_redis.php on line 5

I added additional validation of connection type (by host or socket). Also I fixed condition when RedisSentinel connection call as it supports connections by host only.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@alebedev80alebedev80 changed the title[RedisComponent ]Bug fix a socket connection without port in RedisTrait.php[RedisComponent] Bug fix a socket connection without port in RedisTrait.phpFeb 2, 2022
@alebedev80alebedev80 changed the title[RedisComponent] Bug fix a socket connection without port in RedisTrait.php[CacheComponent] Bug fix a socket connection without port in RedisTrait.phpFeb 2, 2022
@alebedev80
Copy link
ContributorAuthor

alebedev80 commentedFeb 2, 2022
edited
Loading

@kbond I did a first PR to Symfony project and had some issues:

  1. why change from that files also was committed src/Symfony/Component/Mailer/Bridge/Mailchimp/*
  2. tests failed, but on local envirionment they skipped. How to set-up local env so test runs ok?
Symfony\Component\Cache\Exception\InvalidArgumentException: Invalid Redis DSN: "redis://".```Please help me!

@kbond
Copy link
Member

Hey@alebedev80, thanks for contributing!

For (1), a few things:

  1. Not exactly sure why these extra commits are included, did you perhaps merge 6.1 into your PR?
  2. Regardless, 5.4 is where you want to make this change so fetch the latest 5.4 branch from this repo andrebase your branch to it (including only your commits).
  3. You'll then need to change the target of this PR to 5.4 (edit button near the PR title gives this option).

For (2), I think you'll need to run the test suite with theREDIS_HOST env variable set:

REDIS_HOST=... phpunit --group integration

I'm not positive though, let me know if that doesn't work.

alebedev80 reacted with thumbs up emoji

@alebedev80alebedev80 changed the base branch from6.1 to5.4February 2, 2022 15:44
@alebedev80
Copy link
ContributorAuthor

@kbond test failed with an error:

1) Symfony\Component\Cache\Tests\Adapter\RedisAdapterTest::testCreateSocketConnectionSymfony\Component\Cache\Exception\InvalidArgumentException: Redis connection "redis:///var/run/redis/redis.sock" failed: No such file or directory

as i understand test envirionment start a Redis instance

  1. where i can find Redis configuration?
  2. what's a Redis's socket file path?

Thank you!

@kbond
Copy link
Member

I'll have to ping@nicolas-grekas to help with this.

alebedev80 reacted with thumbs up emoji

@alebedev80
Copy link
ContributorAuthor

@nicolas-grekas please help

@nicolas-grekasnicolas-grekas changed the title[CacheComponent] Bug fix a socket connection without port in RedisTrait.php[Cache] Fix connecting to Redis via a socket fileFeb 4, 2022
@nicolas-grekasnicolas-grekas changed the base branch from5.4 to4.4February 4, 2022 16:42
@nicolas-grekasnicolas-grekas modified the milestones:6.1,4.4Feb 4, 2022
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

I've rebased for 4.4, fixed the patch, and fixed the tests.

@carsonbotcarsonbot changed the title[Cache] Fix connecting to Redis via a socket fileFix connecting to Redis via a socket fileFeb 4, 2022
@carsonbotcarsonbot changed the titleFix connecting to Redis via a socket file[Cache] Fix connecting to Redis via a socket fileFeb 4, 2022
@nicolas-grekas
Copy link
Member

Thank you@alebedev80.

@nicolas-grekasnicolas-grekas merged commit12b63b3 intosymfony:4.4Feb 4, 2022
@alebedev80
Copy link
ContributorAuthor

@nicolas-grekas thank you very much!

This was referencedFeb 28, 2022
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

@chalasrchalasrAwaiting requested review from chalasr

@dunglasdunglasAwaiting requested review from dunglas

@lyrixxlyrixxAwaiting requested review from lyrixx

@wouterjwouterjAwaiting requested review from wouterj

@xabbuhxabbuhAwaiting requested review from xabbuh

@ycerutoycerutoAwaiting requested review from yceruto

@jderussejderusseAwaiting requested review from jderussejderusse is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

4 participants

@alebedev80@carsonbot@kbond@nicolas-grekas

[8]ページ先頭

©2009-2025 Movatter.jp