-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Allow queue jobs with batches #3974
Changes from all commits
68b0193
b6c2028
5383e48
0595d0a
3a1aec7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Maatwebsite\Excel\Concerns; | ||
|
||
interface ShouldBatch | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,11 @@ | |
|
||
namespace Maatwebsite\Excel\Jobs; | ||
|
||
use Illuminate\Bus\Batchable; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Maatwebsite\Excel\Concerns\WithEvents; | ||
use Maatwebsite\Excel\Events\ImportFailed; | ||
use Maatwebsite\Excel\HasEventBus; | ||
|
@@ -12,7 +15,7 @@ | |
|
||
class AfterImportJob implements ShouldQueue | ||
{ | ||
use Queueable, HasEventBus; | ||
use Batchable, Queueable, HasEventBus, Dispatchable, ProxyFailures, InteractsWithQueue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Batchable trait doesn't exists < Laravel 8 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're right. this would break compatibility with versions prior to 8 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no security patches for laravel 8 anymore and 9 neither in 3 weeks. you shouldn't encourage people to stay on insecure versions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't endorse nor encourage it. But the package is currently in a situation that dropping support for older versions has an impact on users. Unfortunately the harsh truth looking at packagist installs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I hinted dropping support means nothing for those user, they are already outdated versions of everything, I doubt they ever update anything only running composer install, I'm sure they don't even upgrade security patches, so why would they update your library either? By dropping support in a minor they can still install the older package without the new features if they want with no issues, you do not need to create a major to drop support of a dependency with composer, and even if you do want to bump the version, then what's the issue? Those old users still can't upgrade (Composer will only install the last compatible version) and they likely won't be missing on anything, they'll still have the features they've been using for 6 years or they already would have upgraded their laravel which is quite easy to do in most cases. Upgrading a major just has more friction because all the rest of the users need to bump the required major version manually as well as opposed to just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately the majority of issues opened here are of people using older Laravel versions with the latest version of this package. |
||
|
||
/** | ||
* @var WithEvents | ||
|
@@ -36,6 +39,11 @@ public function __construct($import, Reader $reader) | |
|
||
public function handle() | ||
{ | ||
// Determine if the batch has been cancelled... | ||
if ($this->batch()->cancelled()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would break if ShouldBatch isn't implemented and user would use the old queueing |
||
return; | ||
} | ||
|
||
if ($this->import instanceof ShouldQueue && $this->import instanceof WithEvents) { | ||
$this->reader->clearListeners(); | ||
$this->reader->registerListeners($this->import->registerEvents()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would create a batch with a chain, is that your intention? Would it make sense to add a concern to allow in parallel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the concern is added so that the response is a PendingBatch and then you can add things like batch name, jobs at the end of the batch etc.