diff --git a/.travis.yml b/.travis.yml index 190fc63..9c02597 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,9 @@ cache: - $HOME/.composer/cache php: - - 5.4 - - 5.5 - - 5.6 - 7.0 + - 7.1 + - 7.2 services: - redis-server @@ -19,26 +18,14 @@ env: matrix: - NETTE=nette-2.4-dev - NETTE=nette-2.4 - - NETTE=nette-2.3 matrix: include: - - php: 5.6 - env: NETTE=nette-2.3 COMPOSER_EXTRA_ARGS="--prefer-lowest --prefer-stable" - - php: 7.0 - env: NETTE=nette-2.4 COVERAGE="--coverage ./coverage.xml --coverage-src ./src" TESTER_RUNTIME="phpdbg" - exclude: - - php: 5.4 - env: NETTE=nette-2.4-dev - - php: 5.4 - env: NETTE=nette-2.4 - - php: 5.5 - env: NETTE=nette-2.4-dev - - php: 5.5 - env: NETTE=nette-2.4 + - php: 7.2 + env: NETTE=nette-2.4 COVERAGE="-d memory_limit=4096M --coverage ./coverage.xml --coverage-src ./src" TESTER_RUNTIME="phpdbg" allow_failures: - - php: 7.0 - env: NETTE=nette-2.4 COVERAGE="--coverage ./coverage.xml --coverage-src ./src" TESTER_RUNTIME="phpdbg" + - php: 7.2 + env: NETTE=nette-2.4 COVERAGE="-d memory_limit=4096M --coverage ./coverage.xml --coverage-src ./src" TESTER_RUNTIME="phpdbg" before_install: - travis_retry composer self-update @@ -53,7 +40,6 @@ addons: install: - travis_retry composer update --no-interaction --prefer-dist $COMPOSER_EXTRA_ARGS - travis_retry composer create-project --no-interaction jakub-onderka/php-parallel-lint /tmp/php-parallel-lint - - travis_retry composer create-project --no-interaction kdyby/code-checker /tmp/code-checker - travis_retry wget -O /tmp/coveralls.phar https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar - tests/travis.phpredis.sh - redis-cli info |grep version @@ -61,7 +47,6 @@ install: script: - vendor/bin/tester $COVERAGE -s -p ${TESTER_RUNTIME:-php} -c ./tests/php.ini-unix ./tests/KdybyTests/ - php /tmp/php-parallel-lint/parallel-lint.php -e php,phpt --exclude vendor . - - php /tmp/code-checker/src/code-checker.php --short-arrays after_script: - if [ "$COVERAGE" != "" ]; then php /tmp/coveralls.phar --verbose --config tests/.coveralls.yml || true; fi diff --git a/README.md b/README.md index ca9ba4e..535d1bd 100755 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Kdyby/Redis Requirements ------------ -Kdyby/Redis requires PHP 5.4 or higher. +Kdyby/Redis requires PHP 7.0 or higher. - [Nette Framework](https://github.com/nette/nette) - [Redis database](http://redis.io) diff --git a/composer.json b/composer.json index 2ace427..5aa3b89 100644 --- a/composer.json +++ b/composer.json @@ -17,37 +17,37 @@ "issues": "https://github.com/kdyby/redis/issues" }, "require": { - "php": ">=5.4", - "nette/di": "~2.3@dev", - "nette/caching": "~2.3@dev", - "nette/http": "~2.3@dev", - "nette/utils": "~2.3@dev" + "php": ">=7.0", + "nette/di": "~2.4", + "nette/caching": "~2.5", + "nette/http": "~2.4", + "nette/utils": "~2.4" }, "suggest": { "ext-redis": "The php redis extension https://github.com/nicolasff/phpredis/ is required for connecting to redis server" }, "require-dev": { - "nette/application": "~2.3@dev", - "nette/bootstrap": "~2.3@dev", - "nette/caching": "~2.3@dev", - "nette/component-model": "~2.2@dev", - "nette/database": "~2.3@dev", - "nette/deprecated": "~2.2@dev", - "nette/di": "~2.3@dev", - "nette/finder": "~2.3@dev", - "nette/forms": "~2.3@dev", - "nette/http": "~2.3@dev", - "nette/mail": "~2.3@dev", - "nette/neon": "~2.3@dev", - "nette/php-generator": "~2.3@dev", - "nette/reflection": "~2.3@dev", - "nette/robot-loader": "~2.3@dev", - "nette/safe-stream": "~2.3@dev", - "nette/security": "~2.3@dev", - "nette/tokenizer": "~2.2@dev", - "nette/utils": "~2.3@dev", - "latte/latte": "~2.3@dev", - "tracy/tracy": "~2.3@dev", + "nette/application": "~2.4", + "nette/bootstrap": "~2.4", + "nette/caching": "~2.5", + "nette/component-model": "~2.3", + "nette/database": "~2.4", + "nette/deprecated": "~2.4", + "nette/di": "~2.4", + "nette/finder": "~2.4", + "nette/forms": "~2.4", + "nette/http": "~2.4", + "nette/mail": "~2.4", + "nette/neon": "~2.4", + "nette/php-generator": "~2.6", + "nette/reflection": "~2.4", + "nette/robot-loader": "~2.4", + "nette/safe-stream": "~2.3", + "nette/security": "~2.4", + "nette/tokenizer": "~2.3", + "nette/utils": "~2.4", + "latte/latte": "~2.4", + "tracy/tracy": "~2.4", "nette/tester": "~1.7" }, @@ -64,7 +64,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "4.0-dev" } } } diff --git a/src/Kdyby/Redis/Diagnostics/Panel.php b/src/Kdyby/Redis/Diagnostics/Panel.php index c404648..b544713 100644 --- a/src/Kdyby/Redis/Diagnostics/Panel.php +++ b/src/Kdyby/Redis/Diagnostics/Panel.php @@ -22,8 +22,9 @@ /** * @author Filip Procházka */ -class Panel extends Nette\Object implements IBarPanel +class Panel implements IBarPanel { + use Nette\SmartObject; /** @internal */ const TIMER_NAME = 'redis-client-timer'; diff --git a/src/Kdyby/Redis/ExclusiveLock.php b/src/Kdyby/Redis/ExclusiveLock.php index 655a9a5..11ec7e5 100644 --- a/src/Kdyby/Redis/ExclusiveLock.php +++ b/src/Kdyby/Redis/ExclusiveLock.php @@ -19,8 +19,9 @@ * @author Ondřej Nešpor * @author Filip Procházka */ -class ExclusiveLock extends Nette\Object +class ExclusiveLock { + use Nette\SmartObject; /** * @var RedisClient diff --git a/src/Kdyby/Redis/RedisClient.php b/src/Kdyby/Redis/RedisClient.php index cdcb450..8225901 100644 --- a/src/Kdyby/Redis/RedisClient.php +++ b/src/Kdyby/Redis/RedisClient.php @@ -154,8 +154,9 @@ * * @author Filip Procházka */ -class RedisClient extends Nette\Object implements \ArrayAccess +class RedisClient implements \ArrayAccess { + use Nette\SmartObject; /** @deprecated */ const WITH_SCORES = 'WITHSCORES'; diff --git a/src/Kdyby/Redis/RedisJournal.php b/src/Kdyby/Redis/RedisJournal.php index 163ed5b..09ca4af 100644 --- a/src/Kdyby/Redis/RedisJournal.php +++ b/src/Kdyby/Redis/RedisJournal.php @@ -20,8 +20,9 @@ * * @author Filip Procházka */ -class RedisJournal extends Nette\Object implements Nette\Caching\Storages\IJournal +class RedisJournal implements Nette\Caching\Storages\IJournal { + use Nette\SmartObject; /** @internal cache structure */ const NS_NETTE = 'Nette.Journal'; diff --git a/src/Kdyby/Redis/RedisSessionHandler.php b/src/Kdyby/Redis/RedisSessionHandler.php index eb2d05d..22ba88c 100644 --- a/src/Kdyby/Redis/RedisSessionHandler.php +++ b/src/Kdyby/Redis/RedisSessionHandler.php @@ -24,8 +24,9 @@ * * @author Filip Procházka */ -class RedisSessionHandler extends Nette\Object implements \SessionHandlerInterface +class RedisSessionHandler implements \SessionHandlerInterface { + use Nette\SmartObject; /** @internal cache structure */ const NS_NETTE = 'Nette.Session:'; diff --git a/src/Kdyby/Redis/RedisStorage.php b/src/Kdyby/Redis/RedisStorage.php index a905e2f..9726e6a 100644 --- a/src/Kdyby/Redis/RedisStorage.php +++ b/src/Kdyby/Redis/RedisStorage.php @@ -22,8 +22,9 @@ * * @author Filip Procházka */ -class RedisStorage extends Nette\Object implements IMultiReadStorage +class RedisStorage implements IMultiReadStorage { + use Nette\SmartObject; /** @internal cache structure */ const NS_NETTE = 'Nette.Storage'; diff --git a/tests/KdybyTests/Redis/AbstractRedisTestCase.php b/tests/KdybyTests/Redis/AbstractRedisTestCase.php index e6beff4..8d102f0 100644 --- a/tests/KdybyTests/Redis/AbstractRedisTestCase.php +++ b/tests/KdybyTests/Redis/AbstractRedisTestCase.php @@ -203,8 +203,9 @@ public function end() /** * @author Filip Procházka */ -class ClosureExtractor extends Nette\Object +class ClosureExtractor { + use Nette\SmartObject; /** * @var GlobalFunction @@ -263,8 +264,9 @@ public function buildScript(\ReflectionClass $class, $repeat) /** * @author Filip Procházka */ -class NamespaceUses extends Nette\Object +class NamespaceUses { + use Nette\SmartObject; /** * @var \ReflectionClass @@ -395,8 +397,9 @@ private function parseFile() /** * @author Filip Procházka */ -class FunctionCode extends Nette\Object +class FunctionCode { + use Nette\SmartObject; /** * @var \ReflectionFunctionAbstract diff --git a/tests/KdybyTests/Redis/Extension.phpt b/tests/KdybyTests/Redis/Extension.phpt index f98f532..5a2ff9e 100644 --- a/tests/KdybyTests/Redis/Extension.phpt +++ b/tests/KdybyTests/Redis/Extension.phpt @@ -49,8 +49,8 @@ class ExtensionTest extends Tester\TestCase Assert::true($dic->getService('redis.cacheStorage') instanceof Kdyby\Redis\RedisStorage); Assert::true($dic->getService('cacheStorage') instanceof Kdyby\Redis\RedisStorage); Assert::same([ - 'saveHandler' => 'redis', - 'savePath' => 'tcp://127.0.0.1:6379?weight=1&timeout=10&database=0&prefix=Nette.Session%3A', + 'save_handler' => 'redis', + 'save_path' => 'tcp://127.0.0.1:6379?weight=1&timeout=10&database=0&prefix=Nette.Session%3A', 'referer_check' => '', 'use_cookies' => 1, 'use_only_cookies' => 1, @@ -61,10 +61,6 @@ class ExtensionTest extends Tester\TestCase 'cookie_secure' => FALSE, 'cookie_httponly' => TRUE, 'gc_maxlifetime' => 10800, - 'cache_limiter' => NULL, - 'cache_expire' => NULL, - 'hash_function' => NULL, - 'hash_bits_per_character' => NULL, ], $dic->getService('session')->getOptions()); } diff --git a/tests/KdybyTests/Redis/RedisSessionHandler.phpt b/tests/KdybyTests/Redis/RedisSessionHandler.phpt index 7c6b538..60bd81b 100644 --- a/tests/KdybyTests/Redis/RedisSessionHandler.phpt +++ b/tests/KdybyTests/Redis/RedisSessionHandler.phpt @@ -84,13 +84,13 @@ class SessionHandlerTest extends AbstractRedisTestCase public function testIntegration_existingSession() { $sessionId = md5(1); - $session = self::createSession([session_name() => $sessionId, 'nette-browser' => $B = '1lm7e5iqsk']); + $session = self::createSession([session_name() => $sessionId]); $session->setHandler($handler = new SessionHandlerDecorator(new RedisSessionHandler($this->client))); $this->client->setupLockDuration(60, 20); // fake session - $this->client->set('Nette.Session:' . $sessionId, '__NF|' . serialize(['Time' => $T = time() - 1000, 'B' => $B])); + $this->client->set('Nette.Session:' . $sessionId, '__NF|' . serialize(['Time' => $T = time() - 1000])); $counter = $session->getSection('counter'); $counter->visits += 1; @@ -110,12 +110,12 @@ class SessionHandlerTest extends AbstractRedisTestCase Assert::same(['open', '', 'PHPSESSID'], $handler->series[0][0]); Assert::same(['read', $sessionId], $handler->series[0][1]); Assert::same('write', $handler->series[0][2][0]); - Assert::match('__NF|a:3:{s:4:"Time";i:%S%;s:1:"B";s:10:"%S%";s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:1;}}}', $handler->series[0][2][2]); + Assert::match('__NF|a:2:{s:4:"Time";i:%S%;s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:1;}}}', $handler->series[0][2][2]); Assert::same(['open', '', 'PHPSESSID'], $handler->series[1][0]); Assert::same(['read', $sessionId], $handler->series[1][1]); Assert::same('write', $handler->series[1][2][0]); - Assert::match('__NF|a:3:{s:4:"Time";i:%S%;s:1:"B";s:10:"%S%";s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:2;}}}', $handler->series[1][2][2]); + Assert::match('__NF|a:2:{s:4:"Time";i:%S%;s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:2;}}}', $handler->series[1][2][2]); Assert::count(1, $this->client->keys('Nette.Session:*')); } @@ -151,15 +151,15 @@ class SessionHandlerTest extends AbstractRedisTestCase Assert::same('read', $handler1->series[1][1][0]); Assert::match('%S%', $regeneratedId = $handler1->series[1][1][1]); Assert::same('write', $handler1->series[1][2][0]); - Assert::match('__NF|a:2:{s:4:"Time";i:%S%;s:1:"B";s:10:"%S%";}', $handler1->series[1][2][2]); + Assert::match('__NF|a:1:{s:4:"Time";i:%S%;}', $handler1->series[1][2][2]); // close session Assert::same('write', $handler1->series[2][2][0]); - Assert::match('__NF|a:3:{s:4:"Time";i:%S%;s:1:"B";s:10:"%S%";s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:1;}}}', $handler1->series[2][2][2]); + Assert::match('__NF|a:2:{s:4:"Time";i:%S%;s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:1;}}}', $handler1->series[2][2][2]); Assert::notSame($sessionId, $regeneratedId); - $session2 = self::createSession([session_name() => $regeneratedId, 'nette-browser' => $_SESSION['__NF']['B']]); // no browser, empty session + $session2 = self::createSession([session_name() => $regeneratedId]); // no browser, empty session $session2->setHandler($handler2 = new SessionHandlerDecorator(new RedisSessionHandler($client = new RedisClient()))); $client->setupLockDuration(60, 20); @@ -173,7 +173,7 @@ class SessionHandlerTest extends AbstractRedisTestCase Assert::same(['open', '', 'PHPSESSID'], $handler2->series[0][0]); Assert::same(['read', $regeneratedId], $handler2->series[0][1]); Assert::same('write', $handler2->series[0][2][0]); - Assert::match('__NF|a:3:{s:4:"Time";i:%S%;s:1:"B";s:10:"%S%";s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:2;}}}', $handler2->series[0][2][2]); + Assert::match('__NF|a:2:{s:4:"Time";i:%S%;s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:2;}}}', $handler2->series[0][2][2]); Assert::count(1, $this->client->keys('Nette.Session:*')); } @@ -216,11 +216,11 @@ class SessionHandlerTest extends AbstractRedisTestCase { $sessionId = md5(1); - $session = self::createSession([session_name() => $sessionId, 'nette-browser' => $B = '1lm7e5iqsk']); + $session = self::createSession([session_name() => $sessionId]); $session->setHandler($handler = new SessionHandlerDecorator(new RedisSessionHandler($client = new RedisClient()))); // fake session - $client->set('Nette.Session:' . $sessionId, '__NF|' . serialize(['Time' => $T = time() - 1000, 'B' => $B])); + $client->set('Nette.Session:' . $sessionId, '__NF|' . serialize(['Time' => $T = time() - 1000])); // open session $counter = $session->getSection('counter'); @@ -232,19 +232,18 @@ class SessionHandlerTest extends AbstractRedisTestCase Assert::same(['open', '', 'PHPSESSID'], $handler->series[0][0]); Assert::same(['read', $sessionId], $handler->series[0][1]); Assert::same('write', $handler->series[0][2][0]); - Assert::match('__NF|a:3:{s:4:"Time";i:%S%;s:1:"B";s:10:"%S%";s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:0;}}}', $handler->series[0][2][2]); + Assert::match('__NF|a:2:{s:4:"Time";i:%S%;s:4:"DATA";a:1:{s:7:"counter";a:1:{s:6:"visits";i:0;}}}', $handler->series[0][2][2]); // only testing the behaviour of high concurency for one request, without regenerating the session id // 30 processes will be started, but every one of them will work for at least 1 second // a fuckload (~66%) of the processes should actually fail, because the timeout for lock acquire is 10 sec - $result = $this->threadStress(function () use ($sessionId, $B) { + $result = $this->threadStress(function () use ($sessionId) { $_COOKIE[session_name()] = $sessionId; - $_COOKIE['nette-browser'] = $B; $session = new Nette\Http\Session( new Nette\Http\Request( new Nette\Http\UrlScript('http://www.kdyby.org'), - NULL, [], [], [session_name() => $sessionId, 'nette-browser' => $B], [], 'GET' + NULL, [], [], [session_name() => $sessionId], [], 'GET' ), new Nette\Http\Response() ); diff --git a/tests/travis.phpredis.sh b/tests/travis.phpredis.sh index 2cbbadc..d28749b 100755 --- a/tests/travis.phpredis.sh +++ b/tests/travis.phpredis.sh @@ -2,13 +2,7 @@ mkdir /tmp/build-phpredis && cd /tmp/build-phpredis || exit 1 -if [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then - PHP_REDIS_BRANCH="php7" -else - PHP_REDIS_BRANCH="master" -fi - -wget -O phpredis.zip "https://github.com/phpredis/phpredis/archive/$PHP_REDIS_BRANCH.zip" && unzip phpredis.zip && cd phpredis-*/ || exit 1 +wget -O phpredis.zip "https://github.com/phpredis/phpredis/archive/master.zip" && unzip phpredis.zip && cd phpredis-*/ || exit 1 echo phpize && ./configure && make && make install || exit 1