Skip to content

Commit 6ec0f65

Browse files
committed
Add Laravel 8 support
1 parent b088181 commit 6ec0f65

5 files changed

+30
-13
lines changed

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ dist: trusty
22
language: php
33

44
php:
5-
- 5.6
65
- 7.0
76
- 7.1
87
- 7.2
@@ -18,7 +17,7 @@ cache:
1817

1918
matrix:
2019
include:
21-
- php: 5.6
20+
- php: 7.0
2221
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
2322

2423
before_script:

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to `expbackoffworker` will be documented in this file.
44

55
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
66

7+
## [3.0.0] - 2021-08-01
8+
9+
### Added
10+
- Compatibility with Laravel 8
11+
12+
### Removed
13+
- Compatibility with Laravel 5 and 6 _(use `2.X.X` instead)_
14+
- Compatibility with PHP 5.6 _(officially; it was broken already)_
15+
716
## [2.1.0] - 2019-06-06
817

918
### Added

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.6.4",
15-
"illuminate/queue": "5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|6.*",
16-
"illuminate/support": "5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|6.*"
14+
"php": ">=7.0",
15+
"illuminate/queue": "8.*",
16+
"illuminate/support": "8.*"
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": "~6.0"

src/QueueServiceProvider.php

+14-5
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,25 @@ class QueueServiceProvider extends IlluminateQueueServiceProvider
1212
*/
1313
protected function registerWorker()
1414
{
15-
$this->app->singleton('queue.worker', function () {
15+
$this->app->singleton('queue.worker', function ($app) {
1616
$isDownForMaintenance = function () {
1717
return $this->app->isDownForMaintenance();
1818
};
1919

20+
$resetScope = function () use ($app) {
21+
if (method_exists($app['log']->driver(), 'withoutContext')) {
22+
$app['log']->withoutContext();
23+
}
24+
25+
return $app->forgetScopedInstances();
26+
};
27+
2028
return new Worker(
21-
$this->app['queue'],
22-
$this->app['events'],
23-
$this->app[ExceptionHandler::class],
24-
$isDownForMaintenance
29+
$app['queue'],
30+
$app['events'],
31+
$app[ExceptionHandler::class],
32+
$isDownForMaintenance,
33+
$resetScope
2534
);
2635
});
2736
}

src/Worker.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class Worker extends IlluminateQueueWorker
1111
* @param string $connectionName
1212
* @param \Illuminate\Contracts\Queue\Job $job
1313
* @param \Illuminate\Queue\WorkerOptions $options
14-
* @param \Exception $e
14+
* @param \Throwable $e
1515
* @return void
1616
*
17-
* @throws \Exception
17+
* @throws \Throwable
1818
*/
1919
protected function handleJobException($connectionName, $job, WorkerOptions $options, $e)
2020
{
21-
$options->delay = (new GetDelay)($options->delay, $job->attempts());
21+
$options->backoff = (new GetDelay)($options->backoff, $job->attempts());
2222

2323
parent::handleJobException($connectionName, $job, $options, $e);
2424
}

0 commit comments

Comments
 (0)