Skip to content

Commit

Permalink
fxing laravel 5 PhpRedisConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyzant committed Apr 14, 2021
1 parent 165ec41 commit 83b0947
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
52 changes: 25 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ dist: trusty
sudo: false

php:
# - 5.6
- 5.6
- 7.0
# - 7.1
# - 7.2
# - 7.3
# - 7.4
- 7.1
- 7.2
- 7.3
- 7.4

env:
# - LARAVEL_VERSION=">=5.4.0 <5.4.20"
# - LARAVEL_VERSION=">=5.4.20 <5.5.0"
# - LARAVEL_VERSION="5.5.*"
# - LARAVEL_VERSION="5.5.*" HORIZON=1
# - LARAVEL_VERSION="5.6.*"
# - LARAVEL_VERSION="5.6.*" HORIZON=1
# - LARAVEL_VERSION="5.7.*"
# - LARAVEL_VERSION="5.7.*" HORIZON=1
# - LARAVEL_VERSION="5.8.*"
# - LARAVEL_VERSION="5.8.*" HORIZON=1
- LARAVEL_VERSION=">=5.4.0 <5.4.20"
- LARAVEL_VERSION=">=5.4.20 <5.5.0"
- LARAVEL_VERSION="5.5.*"
- LARAVEL_VERSION="5.5.*" HORIZON=1
- LARAVEL_VERSION="5.6.*"
- LARAVEL_VERSION="5.6.*" HORIZON=1
- LARAVEL_VERSION="5.7.*"
- LARAVEL_VERSION="5.7.*" HORIZON=1
- LARAVEL_VERSION="5.8.*"
- LARAVEL_VERSION="5.8.*" HORIZON=1
- LARAVEL_VERSION="6.*"
# - LARAVEL_VERSION="6.*" HORIZON=1
# - LARAVEL_VERSION="7.*"
# - LARAVEL_VERSION="7.*" HORIZON=1
# - LUMEN_VERSION="5.4.*"
# - LUMEN_VERSION="5.5.*"
# - LUMEN_VERSION="5.6.*"
# - LUMEN_VERSION="5.7.*"
# - LUMEN_VERSION="5.8.*"
# - LUMEN_VERSION="6.*"
# - LUMEN_VERSION="7.*"
- LARAVEL_VERSION="6.*" HORIZON=1
- LARAVEL_VERSION="7.*"
- LARAVEL_VERSION="7.*" HORIZON=1
- LUMEN_VERSION="5.4.*"
- LUMEN_VERSION="5.5.*"
- LUMEN_VERSION="5.6.*"
- LUMEN_VERSION="5.7.*"
- LUMEN_VERSION="5.8.*"
- LUMEN_VERSION="6.*"
- LUMEN_VERSION="7.*"

matrix:
exclude:
Expand Down Expand Up @@ -126,8 +126,6 @@ before_install:
- if [ -n "$LUMEN_VERSION" ]; then composer require --no-update "laravel/lumen-framework:$LUMEN_VERSION"; fi
- if [ -z "$HORIZON" ]; then composer remove --dev --no-update "laravel/horizon"; fi
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then printf "\n" | pecl install -f redis; fi
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then phpenv config-rm xdebug.ini; fi
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi

install: travis_retry composer install --prefer-dist --no-interaction --no-suggest

Expand Down
14 changes: 14 additions & 0 deletions src/Connections/PhpRedisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
*/
class PhpRedisConnection extends LaravelPhpRedisConnection
{
/**
* The connection creation callback.
*
* Laravel 5 does not store the connector by default.
*
* @var callable
*/
protected $connector;

/**
* The number of times the client attempts to retry a command when it fails
* to connect to a Redis instance behind Sentinel.
Expand Down Expand Up @@ -50,6 +59,11 @@ public function __construct($client, callable $connector = null, array $sentinel
{
parent::__construct($client, $connector);

// Set the connector when it is not set. Used for Laravel 5.
if (! $this->connector) {
$this->connector = $connector;
}

$this->retryLimit = (int) (isset($sentinelOptions['retry_limit']) ? $sentinelOptions['retry_limit'] : 20);
$this->retryWait = (int) (isset($sentinelOptions['retry_wait']) ? $sentinelOptions['retry_wait'] : 1000);
}
Expand Down

0 comments on commit 83b0947

Please sign in to comment.