Skip to content

Commit 1823a77

Browse files
author
Bob Chengbin
authored
Be compatible with Redis::open() and fix Travis CI
2 parents 626e76d + 320d5cb commit 1823a77

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ php:
1010
services:
1111
- redis-server
1212

13-
before_install: v=$(phpenv version-name); if [ ${v:0:1} -lt 7 ]; then pecl install redis; else echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
13+
before_install: v=$(phpenv version-name); if [ ${v:0:1} -lt 7 ]; then pecl install igbinary ; yes | pecl install redis; else echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
1414

1515
install:
16-
- composer global require "fxp/composer-asset-plugin:^1.2.0"
17-
- composer require codeclimate/php-test-reporter --dev
18-
- composer install --no-progress --no-interaction
16+
- composer global require --prefer-dist "fxp/composer-asset-plugin:^1.2.0"
17+
- composer require codeclimate/php-test-reporter --dev --prefer-dist
18+
- composer install --no-progress --no-interaction --prefer-dist
1919

2020
script:
2121
- ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml

Connection.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,29 @@ public static function className()
7777
* Establishes a DB connection.
7878
* It does nothing if a DB connection has already been established.
7979
* @throws RedisException if connection fails
80+
* @example 问题详细描述 https://bugs.php.net/bug.php?id=46851 php_redis.so 版本为4.0.2时会出现一条警告
81+
* @see connect()
82+
* @param string $host
83+
* @param int $port
84+
* @param float $timeout
85+
* @param int $retry_interval
86+
* @return bool
8087
*/
81-
public function open()
88+
public function open( $host = null, $port = null, $timeout = null, $retry_interval = 0 )
8289
{
8390
if ($this->unixSocket !== null) {
8491
$isConnected = $this->connect($this->unixSocket);
8592
} else {
86-
$isConnected = $this->connect($this->hostname, $this->port, $this->connectionTimeout);
93+
if(is_null($host)){
94+
$host = $this->hostname;
95+
}
96+
if(is_null($port)){
97+
$port = $this->port;
98+
}
99+
if(is_null($timeout)){
100+
$timeout = $this->connectionTimeout;
101+
}
102+
$isConnected = $this->connect($host, $port, $timeout, null, $retry_interval);
87103
}
88104

89105
if ($isConnected === false) {

composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,13 @@
2222
"require-dev": {
2323
"phpunit/phpunit": "<6.0",
2424
"yiisoft/yii2-redis": "^2.0"
25+
},
26+
"config": {
27+
"fxp-asset": {
28+
"vcs-driver-options": {
29+
"github-no-api": true
30+
},
31+
"pattern-skip-version": "(-build|-patch)"
32+
}
2533
}
2634
}

0 commit comments

Comments
 (0)