Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump PHP version requirement to 7.1+, support Symfony v4 and v5 components #102

Merged
merged 5 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ _A web interface for this version is currently in development, if you want to kn
You must have the following installed in order to run php-resque:

* [Redis](http://redis.io/)
* [PHP 5.3+](http://php.net/)
* [PHP 7.1+](http://php.net/)
* [PCNTL PHP extension](http://php.net/manual/en/book.pcntl.php)
* [Composer](http://getcomposer.org/)

Expand All @@ -81,7 +81,7 @@ Add php-resque to your application's `composer.json` file:
```json
{
"require": {
"mjphaynes/php-resque": "2.1.*"
"mjphaynes/php-resque": "3.0.*"
}
}
```
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
}
],
"require": {
"php": ">=5.3.0",
"php": ">=7.1.0",
"ext-pcntl": "*",
"predis/predis": "1.1.*",
"monolog/monolog": "~1.7",
"symfony/console": "~2.7|~3.0",
"symfony/yaml": "~2.7|~3.0"
"symfony/console": "~3.0|~4.0|~5.0",
"symfony/yaml": "~3.0|~4.0|~5.0"
},
"suggest": {
"ext-proctitle": "Allows php-resque to rename the title of UNIX processes to show the status of a worker in PHP versions < 5.5.0.",
Expand All @@ -26,7 +26,7 @@
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"symfony/process": "~2.7|~3.0"
"symfony/process": "~3.0|~4.0|~5.0"
},
"bin": [
"bin/resque"
Expand Down
4 changes: 2 additions & 2 deletions src/Resque/Commands/Cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

use Resque;
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -51,5 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->log('Cleaned workers: <pop>'.json_encode(array_merge($cleaned_hosts['workers'], $cleaned_workers)).'</pop>');
$this->log('Cleaned <pop>'.$cleaned_jobs['zombie'].'</pop> zombie job'.($cleaned_jobs['zombie'] == 1 ? '' : 's'));
$this->log('Cleared <pop>'.$cleaned_jobs['processed'].'</pop> processed job'.($cleaned_jobs['processed'] == 1 ? '' : 's'));

return self::SUCCESS;
}
}
4 changes: 2 additions & 2 deletions src/Resque/Commands/Clear.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

use Resque;
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;

Expand Down Expand Up @@ -55,6 +53,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$output->writeln('<pop>Done.</pop>');

return self::SUCCESS;
}
}
}
5 changes: 3 additions & 2 deletions src/Resque/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

use Resque;
use Resque\Helpers\Util;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand All @@ -26,6 +24,9 @@
*/
class Command extends \Symfony\Component\Console\Command\Command
{
public const SUCCESS = 0;
public const FAILURE = 1;
public const INVALID = 2;

/**
* @var Logger The logger instance
Expand Down
4 changes: 2 additions & 2 deletions src/Resque/Commands/Hosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

use Resque;
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

Expand Down Expand Up @@ -56,5 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$this->log((string)$table);

return self::SUCCESS;
}
}
9 changes: 5 additions & 4 deletions src/Resque/Commands/Job/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -70,21 +69,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
$delay = (int)$delay;
} else {
$this->log('Delay option "'.$delay.'" is invalid type "'.gettype($delay).'", value must be an integer.', Logger::ERROR);
return;
return self::INVALID;
}

if ($delay) {
if ($job = Resque::later($delay, $job, $args, $queue)) {
$this->log('Job <pop>'.$job.'</pop> will be queued at <pop>'.date('r', $job->getDelayedTime()).'</pop> on <pop>'.$job->getQueue().'</pop> queue.');
return;
return self::SUCCESS;
}
} else {
if ($job = Resque::push($job, $args, $queue)) {
$this->log('Job <pop>'.$job.'</pop> added to <pop>'.$job->getQueue().'</pop> queue.');
return;
return self::SUCCESS;
}
}

$this->log('Error, job was not queued. Please try again.', Logger::ERROR);

return self::FAILURE;
}
}
4 changes: 2 additions & 2 deletions src/Resque/Commands/Queues.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

use Resque;
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -63,5 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$this->log((string)$table);

return self::SUCCESS;
}
}
4 changes: 2 additions & 2 deletions src/Resque/Commands/Socket/Connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

use Resque;
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -112,5 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

fclose($fh);

return self::SUCCESS;
}
}
4 changes: 2 additions & 2 deletions src/Resque/Commands/Socket/Receive.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Resque;
use Resque\Job;
use Resque\Host;
use Resque\Redis;
use Resque\Worker;
use Resque\Socket;
use Resque\Helpers\Util;
Expand All @@ -23,7 +22,6 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\OutputInterface;

Expand Down Expand Up @@ -285,6 +283,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
});

$server->run();

return self::SUCCESS;
}

public function pollingConsoleOutput()
Expand Down
3 changes: 2 additions & 1 deletion src/Resque/Commands/Socket/Send.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -74,5 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->log('<pop>'.trim($response).'</pop>');

fclose($fh);

return self::SUCCESS;
}
}
5 changes: 2 additions & 3 deletions src/Resque/Commands/SpeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@

use Resque;
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Process;
use Symfony\Component\Console\Helper\ProgressBar;

use Exception;

Expand Down Expand Up @@ -76,6 +73,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
foreach ($keys as $key) {
$redis->del($key);
}

return self::SUCCESS;
}

// http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
Expand Down
5 changes: 3 additions & 2 deletions src/Resque/Commands/Worker/Cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -48,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($id) {
if (false === ($worker = Resque\Worker::hostWorker($id))) {
$this->log('There is no worker with id "'.$id.'".', Resque\Logger::ERROR);
return;
return self::FAILURE;
}

$workers = array($worker);
Expand All @@ -74,5 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->log('Worker <pop>'.$worker.'</pop> has no running job.');
}
}

return self::SUCCESS;
}
}
6 changes: 3 additions & 3 deletions src/Resque/Commands/Worker/Pause.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -48,7 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($id) {
if (false === ($worker = Resque\Worker::hostWorker($id))) {
$this->log('There is no worker with id "'.$id.'".', Resque\Logger::ERROR);
return;
return self::FAILURE;
}

$workers = array($worker);
Expand All @@ -67,5 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->log('Worker <pop>'.$worker.'</pop> <error>could not send USR2 signal.</error>');
}
}

return self::SUCCESS;
}
}
6 changes: 2 additions & 4 deletions src/Resque/Commands/Worker/Restart.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -48,7 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($id) {
if (false === ($worker = Resque\Worker::hostWorker($id))) {
$this->log('There is no worker with id "'.$id.'".', Resque\Logger::ERROR);
return;
return self::FAILURE;
}

$workers = array($worker);
Expand Down Expand Up @@ -89,6 +87,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

exit(0);
return self::SUCCESS;
}
}
4 changes: 2 additions & 2 deletions src/Resque/Commands/Worker/Resume.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -67,5 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->log('Worker <pop>'.$worker.'</pop> <error>could not send CONT signal.</error>');
}
}

return self::SUCCESS;
}
}
4 changes: 2 additions & 2 deletions src/Resque/Commands/Worker/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

use Resque;
use Resque\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -71,6 +69,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$worker->work();

return self::SUCCESS;
}

public function pollingConsoleOutput()
Expand Down
5 changes: 3 additions & 2 deletions src/Resque/Commands/Worker/Stop.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -49,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($id) {
if (false === ($worker = Resque\Worker::hostWorker($id))) {
$this->log('There is no worker with id "'.$id.'".', Resque\Logger::ERROR);
return;
return self::FAILURE;
}

$workers = array($worker);
Expand All @@ -70,5 +69,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->log('Worker <pop>'.$worker.'</pop> <error>could not send '.$sig.' signal.</error>');
}
}

return self::SUCCESS;
}
}
Loading