Views BulkForm should automatically create batch when certain number of entities are selected for performance issues in it's submit handler which is not difficult task at all.
This number should be optional in the BulkForm options 'form'. Also there should be another option to split the entities into chunks so the batch would run faster(also not difficult at all).
I'd write a patch but BulkForm submission is broken in A10 #2239245: BulkForm does not work in Block display
| Comment | File | Size | Author |
|---|---|---|---|
| #42 | 3142893-42.patch | 10.89 KB | kishor_kolekar |
| #35 | interdiff_30_35.txt | 7.83 KB | matroskeen |
| #35 | 2239269-35.patch | 10.6 KB | matroskeen |
Comments
Comment #1
Anonymous (not verified) commentedSomething like this(untested).
Comment #8
mglamanComment #10
andypostComment #11
vacho commentedThe code at core/modules/system/lib/Drupal/system/Plugin/views/field/BulkForm.php has been moved to core/modules/system/src/Plugin/views/field/BulkForm.php and this has been deprecated, so the functional code is in: core/modules/views/src/Plugin/views/field/BulkForm.php
Patch applied to current logic.
Comment #12
vacho commentedComment #13
manuel garcia commentedFirst, I love this idea, let's do it!
I find the
batch_limitoption confusing, and I believe UI users will as well.I'd like to propose a solution to this:
batch_limitbeing more than 1.batch_chunkoption in the form if the batch enable checkbox is checked.batch_chunk < count($entities)to determine if wecreateBatchor not.Comment #14
manuel garcia commentedThis is would be a new feature, so changing the category.
Comment #15
manuel garcia commentedComment #17
vacho commentedComment #18
andypostComment #19
YurkinPark commentedPatch doesn't work for me for several reasons
Need to count with "$selected" variable, $entities variable is empty at this moment. So, batch will never be created. But main reason is some actions (like delete) need a confirmation before action. It means, even we will process executing of delete action in batch, delete action will do nothing during batch session (because it is just creating list of what to confirm). To implement this, we will need changes inside these confirm forms (to catch some context may be with stored info about batch operation)
Comment #21
manuel garcia commentedOnly patch cleanup here. Setting to needs review for the tests to run, but this is still needs work.
Comment #22
manuel garcia commentedmore cleanup
Comment #23
andypostComment #24
manuel garcia commentedFor now just enabled batching on the test view used to test the bulkform functionality.
Comment #25
manuel garcia commentedAdding related issue which demonstrates that you can setup an Action to use batching in code, which is probably a first step in this direction.
Comment #27
manuel garcia commentedAdding the schema for
batch_limitandbatch_chunkComment #29
andypostbtw core using config and settings variables to define default batch size (around 50) so min-max should be considered to be higher
Comment #30
andypostIf we introduce this option then makes sense to adopt it to administrative views and consider default batch size
Also patch fixes config schema naming (chunk instead of chunks)
Comment #31
manuel garcia commentedRe #30:
Thanks for fixing the schema there, oops!
Until #2603820: [PP-1] Allow selecting all entities in a given page or in every pages for bulk operations gets done, doing this would not have any effect since we can't select more items than what's shown on the the first page.
Since these updates mean we'd need an upgrade path & upgrade path tests for the views, I propose we enable this option on #2603820: [PP-1] Allow selecting all entities in a given page or in every pages for bulk operations instead of here, since that’s where it would actually become usable.
Comment #32
batkorsubscribe
Comment #33
lendudeat this point entities is always an empty array right? so I'm assuming this is a work in progress? or am I overlooking something?
We'd need an upgrade path and test for the config change. And obviously tests for the new functionality.
Comment #34
matroskeenComment #35
matroskeenRemaining items:
I'm not sure that any upgrade path is needed, because we have default values for these options.
Comment #36
YurkinPark commentedComment #38
longwaveI agree with #13 in that I am not sure why
batch_limitisn't just a checkbox - what is the use case for havingbatch_limitanything other than 0 or the same value asbatch_chunk? A lower number doesn't make sense at all, and I can't see a good reason for allowing a higher number either.In fact, do we even need a checkbox? If
batch_chunkis 0 then disable batching, otherwise split the batch into that many chunks?Comment #40
andypostComment #41
kishor_kolekar commentedComment #42
kishor_kolekar commentedI have re-roll the patch.
Comment #43
kishor_kolekar commentedComment #45
andypostComment #46
kishor_kolekar commented