From 59738b2ce382016df143d669f0bd7d9e90de2dce Mon Sep 17 00:00:00 2001 From: John Prem Kumar S <36818969+JohnPremKumar@users.noreply.github.com> Date: Wed, 15 Apr 2020 13:15:03 +0530 Subject: [PATCH 1/6] Update Redis.php Added urlencoding and base64encoding for redis password --- lib/Resque/Redis.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Resque/Redis.php b/lib/Resque/Redis.php index cf05444..330e92d 100644 --- a/lib/Resque/Redis.php +++ b/lib/Resque/Redis.php @@ -207,9 +207,8 @@ public static function parseDsn($dsn) $database = intval(preg_replace('/[^0-9]/', '', $parts['path'])); } - // Extract any 'user' and 'pass' values + // Extract any 'user' values $user = isset($parts['user']) ? $parts['user'] : false; - $pass = isset($parts['pass']) ? $parts['pass'] : false; // Convert the query string into an associative array $options = array(); @@ -218,6 +217,20 @@ public static function parseDsn($dsn) parse_str($parts['query'], $options); } + //check 'password-hashing' parameter and extracting password based on encoding + if($options && isset($options['password-hashing']) && $options['password-hashing'] === 'u'){ + //extracting urlencoded password + $pass = isset($parts['pass']) ? urldecode($parts['pass']) : false; + } + else if($options && isset($options['password-hashing']) && $options['password-hashing'] === 'b'){ + //extracting base64 encoded password + $pass = isset($parts['pass']) ? base64_decode($parts['pass']) : false; + } + else{ + //extracting pass directly since 'password-hashing' parameter is not present + $pass = isset($parts['pass']) ? $parts['pass'] : false; + } + return array( $parts['host'], $port, From 996df4910e5080c8a48f08205db3ef38a91eac4d Mon Sep 17 00:00:00 2001 From: John Prem Kumar S <36818969+JohnPremKumar@users.noreply.github.com> Date: Thu, 16 Apr 2020 14:06:20 +0530 Subject: [PATCH 2/6] Update Redis.php changed hashing to encoding as suggested --- lib/Resque/Redis.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Resque/Redis.php b/lib/Resque/Redis.php index 330e92d..0e503b8 100644 --- a/lib/Resque/Redis.php +++ b/lib/Resque/Redis.php @@ -217,17 +217,17 @@ public static function parseDsn($dsn) parse_str($parts['query'], $options); } - //check 'password-hashing' parameter and extracting password based on encoding - if($options && isset($options['password-hashing']) && $options['password-hashing'] === 'u'){ + //check 'password-encoding' parameter and extracting password based on encoding + if($options && isset($options['password-encoding']) && $options['password-encoding'] === 'u'){ //extracting urlencoded password $pass = isset($parts['pass']) ? urldecode($parts['pass']) : false; } - else if($options && isset($options['password-hashing']) && $options['password-hashing'] === 'b'){ + else if($options && isset($options['password-encoding']) && $options['password-encoding'] === 'b'){ //extracting base64 encoded password $pass = isset($parts['pass']) ? base64_decode($parts['pass']) : false; } else{ - //extracting pass directly since 'password-hashing' parameter is not present + //extracting pass directly since 'password-encoding' parameter is not present $pass = isset($parts['pass']) ? $parts['pass'] : false; } From 4a04f887d7afb88496535038bd16ff77a85341ad Mon Sep 17 00:00:00 2001 From: Patrick Romowicz Date: Wed, 28 Apr 2021 01:41:16 +0200 Subject: [PATCH 3/6] Only ping redis if Worker is unpaused (#47) Only ping redis if Worker is unpaused --- lib/Resque/Worker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index 7935cec..a606c44 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -177,7 +177,7 @@ public function work($interval = Resque::DEFAULT_INTERVAL, $blocking = false) // is redis still alive? try { - if (Resque::redis()->ping() === false) { + if (!$this->paused && Resque::redis()->ping() === false) { throw new CredisException('redis ping() failed'); } } catch (CredisException $e) { From 7b791b5e91b7aee45d1e68f4dffefa1a4d72501e Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sat, 3 Jul 2021 18:05:59 +0200 Subject: [PATCH 4/6] Move CI to GitHub actions (#49) * CI: Move to GitHub actions * lib: fix issues found by PHPStan * CI: Install redis for phpunit * CI: remove unused code coverage providers * Add PHPCS config for PSR12-with-tabs Co-authored-by: Dan Hunsaker --- .github/dependabot.yml | 6 +++++ .github/workflows/php-test.yml | 47 ++++++++++++++++++++++++++++++++++ .travis.yml | 23 ----------------- README.md | 6 ++--- lib/Resque/Redis.php | 6 +++++ lib/Resque/Worker.php | 2 +- lib/ResqueScheduler.php | 2 +- phpcs.xml.dist | 15 +++++++++++ 8 files changed, 78 insertions(+), 29 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/php-test.yml delete mode 100644 .travis.yml create mode 100644 phpcs.xml.dist diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..12f28b4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "composer" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml new file mode 100644 index 0000000..d475223 --- /dev/null +++ b/.github/workflows/php-test.yml @@ -0,0 +1,47 @@ +name: PHP Tests +on: [push, pull_request] + +jobs: + php: + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + name: "PHP-${{ matrix.php-versions }}: CS/PHPStan/PHPUnit" + strategy: + matrix: + php-versions: ['7.3', '7.4'] + experimental: [false] + include: + - php-versions: '8.0' + experimental: true + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: cs2pr, phpcs, phpstan, phpunit + extensions: redis + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: Run PHPCS + continue-on-error: true + run: phpcs -q --report=checkstyle lib | cs2pr + + - name: Install dependencies + run: composer install + + - name: Run PHPStan + run: phpstan analyse lib -l1 + + - name: Install redis + run: sudo apt-get install -y redis-server + + - name: Setup problem matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Run PHPunit + run: phpunit --configuration phpunit.xml.dist \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e9c667e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php - -php: - - '7.4' - - '7.3' - - '7.2' - - '7.1' - - '7.0' - - '5.6' - -env: - - ENABLE_REDIS_EXT=0 - - ENABLE_REDIS_EXT=1 - -matrix: - allow_failures: - - php: '7.4' - - php: '5.6' - -install: - - echo 'error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - sh -c "if [ $ENABLE_REDIS_EXT -eq 1 ]; then echo \"extension=redis.so\" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi" - - composer install diff --git a/README.md b/README.md index e06c13a..ca553ea 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,13 @@ jobs on one or more queues, and processing them later. [![Latest Unstable Version](https://img.shields.io/packagist/vpre/resque/php-resque.svg?style=flat-square)](https://packagist.org/packages/resque/php-resque) [![Downloads](https://img.shields.io/packagist/dt/resque/php-resque.svg?style=flat-square)](https://packagist.org/packages/resque/php-resque) -[![Build Status](https://img.shields.io/travis/resque/php-resque.svg?style=flat-square&logo=travis)](http://travis-ci.org/resque/php-resque) -[![Code Quality](https://img.shields.io/scrutinizer/g/resque/php-resque.svg?style=flat-square&logo=scrutinizer)](https://scrutinizer-ci.com/g/resque/php-resque/) -[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/resque/php-resque.svg?style=flat-square&logo=scrutinizer)](https://scrutinizer-ci.com/g/resque/php-resque/) +[![Build Status](https://img.shields.io/github/checks-status/resque/php-resque/master)]() [![Dependency Status](https://img.shields.io/librariesio/github/resque/php-resque.svg?style=flat-square)](https://libraries.io/github/resque/php-resque) [![Latest Release](https://img.shields.io/github/release/resque/php-resque.svg?style=flat-square&logo=github&logoColor=white)](https://github.com/resque/php-resque) [![Latest Release Date](https://img.shields.io/github/release-date/resque/php-resque.svg?style=flat-square&logo=github&logoColor=white)](https://github.com/resque/php-resque) [![Commits Since Latest Release](https://img.shields.io/github.amrom.workers.devmits-since/resque/php-resque/latest.svg?style=flat-square&logo=github&logoColor=white)](https://github.com/resque/php-resque) -[![Maintenance Status](https://img.shields.io/maintenance/yes/2020.svg?style=flat-square&logo=github&logoColor=white)](https://github.com/resque/php-resque) +[![Maintenance Status](https://img.shields.io/maintenance/yes/2021.svg?style=flat-square&logo=github&logoColor=white)](https://github.com/resque/php-resque) [![Contributors](https://img.shields.io/github/contributors/resque/php-resque.svg?style=flat-square&logo=github&logoColor=white)](https://github.com/resque/php-resque) [![Chat on Slack](https://img.shields.io/badge/chat-Slack-blue.svg?style=flat-square&logo=slack&logoColor=white)](https://join.slack.com/t/php-resque/shared_invite/enQtNTIwODk0OTc1Njg3LWYyODczMTZjMzI2N2JkYWUzM2FlNDk5ZjY2ZGM4Njc4YjFiMzU2ZWFjOGQxMDIyNmE5MTBlNWEzODBiMmVmOTI) diff --git a/lib/Resque/Redis.php b/lib/Resque/Redis.php index 0e503b8..1cbbae3 100644 --- a/lib/Resque/Redis.php +++ b/lib/Resque/Redis.php @@ -29,6 +29,12 @@ class Resque_Redis */ const DEFAULT_DATABASE = 0; + /** + * Connection driver + * @var mixed + */ + private $driver; + /** * @var array List of all commands in Redis that supply a key as their * first argument. Used to prefix keys with the Resque namespace. diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index a606c44..a10512a 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -17,7 +17,7 @@ class Resque_Worker private static $processPrefix = 'resque'; /** - * @var LoggerInterface Logging object that impliments the PSR-3 LoggerInterface + * @var Psr\Log\LoggerInterface Logging object that impliments the PSR-3 LoggerInterface */ public $logger; diff --git a/lib/ResqueScheduler.php b/lib/ResqueScheduler.php index 986f89a..a4d6c6a 100644 --- a/lib/ResqueScheduler.php +++ b/lib/ResqueScheduler.php @@ -87,7 +87,7 @@ public static function getDelayedQueueScheduleSize() */ public static function getDelayedTimestampSize($timestamp) { - $timestamp = self::toTimestamp($timestamp); + $timestamp = self::getTimestamp($timestamp); return Resque::redis()->llen('delayed:' . $timestamp, $timestamp); } diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..552171d --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,15 @@ + + + PSR2 with tabs instead of spaces. + + + + + + + + + + + + \ No newline at end of file From cf26042893791eb06c2d470583814a3e99512da1 Mon Sep 17 00:00:00 2001 From: demetrius-edelin Date: Mon, 15 Nov 2021 18:21:26 +0200 Subject: [PATCH 5/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 133310e..05c3dd3 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "resque/php-resque", + "name": "cakemail/php-resque", "type": "library", "description": "Redis backed library for creating background jobs and processing them later. Based on resque for Ruby.", "keywords": ["job", "background", "redis", "resque"], From 5c9ba93a5e897a98d36953b7840ea0c13929ebe6 Mon Sep 17 00:00:00 2001 From: demetrius-edelin Date: Mon, 15 Nov 2021 18:23:12 +0200 Subject: [PATCH 6/6] Update Worker.php --- lib/Resque/Worker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index a10512a..939932f 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -209,7 +209,7 @@ public function work($interval = Resque::DEFAULT_INTERVAL, $blocking = false) if($blocking === false) { // If no job was found, we sleep for $interval before continuing and checking again - $this->logger->log(Psr\Log\LogLevel::INFO, 'Sleeping for {interval}', array('interval' => $interval)); + // $this->logger->log(Psr\Log\LogLevel::INFO, 'Sleeping for {interval}', array('interval' => $interval)); if($this->paused) { $this->updateProcLine('Paused'); }