Problem/Motivation
A batch builder object was added in #2401797: Introduce a batch builder class to make the batch API easier to use. The Drupal core should be updated to use the batch builder.
The code to update can most easily be found by looking for the uses of batch_set()
. Example usage is in the class comment for \Drupal\Core\Batch\BatchBuilder
.
Proposed resolution
Use BatchBuilder in the following core modules:
- config - #2875283: Update config module to use the new batch builder
- locale - #2875288: Update locale module to use the new batch builder
- migrate_drupal_ui - #2875291: Update migrate_drupal_ui module to use the new batch builder
- node - #2875292: Update node module to use the new batch builder
- simpletest - #2875295: Update simpletest module to use the new batch builder
- system - #2875296: Update system module to use the new batch builder
- update - #2875300: Update update module to use the new batch builder
- user - #2875307: Update user module to use the new batch builder
Remaining tasks
Fix remaining test failures/code review items in the following core modules:simpletestsystemupdate
- Review patch
- needs a followup
List of contributors
overall: john@johncook.me.uk
, mradcliffe
- config: rajeshwari10 at Valuebound, RajeevK at Sirius, Yogesh Pawar at QED42, James.Shee
- locale: lcngeo
- migrate_drupal_ui: rajeshwari10 at Valuebound, RajeevK at Sirius, Yogesh Pawar at QED42
- node: rajeshwari10 at Valuebound, RajeevK at Sirius, borisson_
- simpletest: time2buzzthetower, RajeevK at Sirius
- system: ccasals at Portland Webworks
- update: kavo
- user: ccasals at Portland Webworks
Comment | File | Size | Author |
---|
Issue fork drupal-2875279
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2875279-update-core-modules changes, plain diff MR !718
Comments
Comment #2
John Cook CreditAttribution: John Cook commentedComment #3
John Cook CreditAttribution: John Cook commentedComment #6
John Cook CreditAttribution: John Cook commentedUpdated the summary.
Comment #7
alexpottPlease let's do the sub issues here in one patch rather than multiple patches. They are the same task - see https://www.drupal.org/core/scope
Comment #8
mradcliffeHere's a combined patch from all the closed child issues. It'll probably fail tests and get back to Needs Work based on some of the child issues.
I added contributors from the child issues to the issue summary and removed the Meta since it's no longer a meta.
Comment #9
mradcliffeAdding some of my reviews:
I found that _locale_translation_batch_status_operations is a wrapper for generating multiple operations using the 'locale_translation_batch_status_check' callback. I think we may need to think of a way to keep adding multiple operations?
Maybe BatchBuilder should be able to add multiple operations in a new addOperations method?
I'm not sure if this is the correct callback for this batch.
_locale_translation_batch_status_operations() returns an array of operations based on some logic and the operation is
locale_translation_batch_status_check
.Additionally I think that we would need to add a @deprecated annotation into the _locale_translation_batch_status_operations function if it's no longer needed.
Same as above.
Same as above. Operation is
locale_translation_batch_status_check
?Missing a $this->t() instead of t().
I think these need multiple addOperation calls unless BatchBuilder can accept multiple operations in a new method.
Shouldn't this be
addOperation('_batch_test_Callback_2', [1, $total, $sleep])
instead?Comment #10
John Cook CreditAttribution: John Cook at Creode commentedComment #11
John Cook CreditAttribution: John Cook at Creode commentedThe patch from #8 needed a re-roll, so here it is.
I'm still expecting this to fail many tests and this patch does not address any of the points from @mradcliffe.
Comment #13
John Cook CreditAttribution: John Cook at Creode commentedI've made a new patch that addresses point 1 - 3 from #9 by @mradcliffe.
I'll have a look at the rest of the problems shortly.
Comment #14
John Cook CreditAttribution: John Cook at Creode commentedAnother patch. This one to address point 4–6 from #9.
I'm still expecting a lot of failed tests.
Comment #15
John Cook CreditAttribution: John Cook at Creode commentedFixed a bug in the
DbUpdateController
class.Comment #16
John Cook CreditAttribution: John Cook at Creode commentedI've discovered that the
callable
type hint requires that the function be in memory, especially when running tests.Because for this I've added an
include_once
when the::setFile()
is called on aBatchBuilder
object. The method calls also need to be in the correct order, with the call to::setFile()
being before the methods that set the callback functions.I'm adding the novice tag for changing the order of the method calls for the error-ing tests.
Comment #17
John Cook CreditAttribution: John Cook at Creode commentedI've removed the inclusion of a file that no longer exists.
Comment #18
John Cook CreditAttribution: John Cook at Creode commentedComment #19
John Cook CreditAttribution: John Cook at Creode commentedThere is currently a bug with Batch API and non-progressive batches and a work around is currently required.
The progressive/non-progressive bug has already been raised as #638712: Make non-progressive batch operations possible.
Comment #20
John Cook CreditAttribution: John Cook at Creode commentedThe changes in comment #16 broke one of the BatchBuilder's own tests. This update fixes that test.
Comment #21
John Cook CreditAttribution: John Cook at Creode commentedThere were a couple of rouge references to
$this
in some functions (not part of a class). This patch removes them.Comment #22
John Cook CreditAttribution: John Cook at Creode commentedI've worked on the few failing tests from #21.
Comment #23
John Cook CreditAttribution: John Cook at Creode commentedAddressed the coding standards from the testbot.
Removed the novice tag.
Comment #24
alexpottLet's put this file in core/modules/system/tests/fixtures/batch
it's not part of that test module really.
Also this test shouldn't be in system. It should be in core/tests/Drupal/Tests/Core/Batch - can you open an issue to move it there?
Comment #25
John Cook CreditAttribution: John Cook at Creode commentedI've created a new issue to move the test class – #2982983: Batch Builder tests in the wrong location.
And 'batch_test.set_file_test.inc' has been moved as requested.
Comment #27
John Cook CreditAttribution: John Cook at Creode commentedFixed the merge conflict.
Comment #29
John Cook CreditAttribution: John Cook at Creode commentedRe-rolled #27 because of recent commits.
Comment #31
joachim CreditAttribution: joachim as a volunteer commentedThis change looks like it's fixing a bug in BatchBuilder itself. That's out of scope for this issue, surely?
Comment #32
quietone CreditAttribution: quietone as a volunteer commentedChanging to NW for the question in #31.
Comment #33
John Cook CreditAttribution: John Cook at Creode commentedI've created a new issue for comment #31. #3028621: BatchBuilder included files fails
Comment #34
John Cook CreditAttribution: John Cook at Creode commentedA re-roll of the commit from #29.
Comment #35
John Cook CreditAttribution: John Cook at Creode commentedI've removed the bug fix code from the patch, but that means that this is now dependent on #3028621: BatchBuilder included files fails being committed.
Comment #36
John Cook CreditAttribution: John Cook at Creode commentedRemoved a testing file that is now provided elsewhere.
Comment #40
andypostComment #41
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedComment #42
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedRerolled patch #36 for 9.1.x, please review.
Comment #44
jpatel657 CreditAttribution: jpatel657 at Trigyn Technologies Ltd commentedComment #45
jpatel657 CreditAttribution: jpatel657 at Trigyn Technologies Ltd commentedCode sniffer has been updated..
Comment #47
jungleLet's postpone this on #3028621: BatchBuilder included files fails
Comment #48
jungleThe blocker is in, re-queued a test.
Comment #49
jungleClass/callbacks should not be changed.
Comment #50
jungleParameter lost
Comment #51
jungleRoom to improve/micro optimization in
_batch_test_batch_*()
. could do in a separate issue. Fewer iterations$total < 10
, smaller $sleep if possible?Comment #52
volegerAdded some missing replacements and removed the redundant variable.
Comment #53
jungle@voleger, many thanks for fixing the tests.
Refactoring a bit to keep them consistent like below.
Comment #54
jungleContinue with #53
Type hints are unnecessary here. Unlike other variables, without it, autocomplete feature in PHPStorm still works.
Comment #55
jungle#3028621 is relevant to this, which is a bug, so tagging Bug Smash Initiative as well.
Comment #56
quietone CreditAttribution: quietone as a volunteer commentedDue to my interest in migrate I started at the migrate drupal ui form and reviewed to the end, missing the beginning of the patch. Now, my eyes have had enough so not looking at the first part of the patch.
The tests are passing and there are no coding standard notifications. Nice.
I noticed that the added use statement is inconsistently placed, sometimes it is in alphabetical order and sometimes not. I find it easier to skim that list if they are in alphabetical order so, if possible, let's make that consistent. Another inconsistency is the change from t() to $this->t(). I think changing those is out of scope for this issue so should be removed. Unless, of course, I am wrong about that.
Please keep in alphabetical order.
Can we keep this is alphabetical order?
Why is this removed?
Why is the second parameter removed?
Why is the second parameter removed?
Also out of alpha order.
Should this todo stay?
Why is this batch no longer needed?
Comment #57
jungle@quietone, many thanks for your detailed review!
use
statements order in 12 files related, including #56.1, 2 and 6I think it's ok. in classes/traits we use $this->t() if possible, otherwise, use t().
Comment #58
jungleSelf review, the 2nd comment is wrong.
Comment #59
quietone CreditAttribution: quietone as a volunteer commented@jungle, oh, sorry. I think I didn't explain the alphabetization of the use statement clearly. I mean just add the
use Drupal\Core\Batch\BatchBuilder;
in the 'best' alphabetical position possible. That is, where the use statements are already ordered it should be easy to add this new line. When this list is not order, do the best one can. Alphabetizing the whole list of use statements is out of scope.Comment #60
jungleRe #59 @quietone, no worries, however, as I already did, I do not think it's necessary to revert them, or if you think it's necessary, setting back to NW, please, thanks!
Comment #61
jonathanshawOut of scope?
Duplicate setErrorMessage
Is the effect of this array_merge replicated?
Comment #62
quietone CreditAttribution: quietone as a volunteer commentedNW for #61 and #59 (to stay strictly in scope).
Comment #63
jungle@quietone, @jonathanshaw, thanks for reviewing!
Addressing #59 and #61.1, 2.
Re #61.3. Should be ok,
array_merge()
is not used anymore.And, BTW,
$batch_builder
is an object. no need to prepend&
Comment #64
jungleLeftover, removing.
Comment #65
jonathanshawout of scope?
Missing setProgressMessage('')
Otherwise RTBC I think.
I've tried to read through it all and check every batch builder call perfectly duplicates the original.
Comment #66
jungle@jonathanshaw many thanks for the great review!
Hopefully, this is the last iteration. I did a self-review as well.
Addressing #65
Comment #67
jonathanshawComment #68
jungle@jonathanshaw, thanks for RTBC-ing.
Uploading a patch for 8.9.x which should be applicable to 9.0.x as well,
Comment #69
alexpottThese methods are marked @internal but I don't think we should optimise this here. We should continue to call them and do something like
And then file a follow-up to do this - where can discus any BC implications properly. I've not found any contrib usages. So we might decide to go forward as is but having this as part of this change makes it harder to have that discussion.
These changes make it header to read than it was and in other places we've kept the single line. Why are we doing this here?
Note as a task and one that should not result in any underlying change this will only get committed to the latest development branch.
Comment #70
jungleThanks @alexpott!
#69.1, a great feedback!
Re #69.2
Per
Drupal.Arrays.Array.LongLineDeclaration
, for example, even it's an unapplied rule ATM. i am going to changing,to
Instead of a single line.
$batch_builder->addOperation('locale_translation_batch_fetch_import', [$project, $langcode, $options]);
Comment #71
jungleAlthough, by default, the 2nd parameter is [], adding back still. And addressing #69.
Comment #72
quietone CreditAttribution: quietone as a volunteer commentedReally nice to see the progress here. Just a few things I noticed.
In #51, this was tagged as needs followup. I could not find where the followup was made. Setting to NW.
I reviewed the patch and notice two inconsistencies, one is that sometimes t() is replaced with $this-t() and sometimes when an array spans longer that 80 characters it is broken into multiple lines and sometimes that is not done (also reported in $69). For me, both of those changes are out of scope and do add to the time it takes to review the patch. There is enough to review here that adding those changes, and done inconsistently, makes this harder to review.
There are many changes like this where the line is greater than 80 characters and the array is not split onto multiple lines. Which is correct here as that would be out of scope.
And yet, as pointed out in #69 this one is changed. I think this is out of scope.
The changes to using $this->t are also out of scope.
As above.
As above.
Comment #75
andypostCould have collision with #3215707: [META] Modernize Locale module
Comment #78
SpokjeUsed
2875279-71.patch
for a reroll on9.3.x
in the new MR.Not addressed anything from #72 (yet).
Comment #79
SpokjeComment #80
Spokje- Addressed #72.2
- Found the same issue in
core/modules/config/src/Form/ConfigSync.php
, addressed that as well.- Addressed #72.5
Not sure if this is because of changes between the review and now, but I found that both #72.3 and #72.4 are currently in both before and after using
$this->t
.So have not addressed those.
Back to NR.
Comment #81
SpokjeComment #82
jonathanshawI'm worried that creating a follow-up for #51 just clogs the issue queue with a task of minor benefit that will never get done. Optimizing the test suite is probably best done systematically using profiling to identify the best places to concentrate attention. It's a possible follow-up but not a NECESSARY one, so no "needs follow-up".
In which case this is RTBC AFAIK.
Comment #83
catchThis looks good to me, but it needs a rebase.
Comment #84
jungleSetting back to RTBC
Comment #93
catchAdding commit credit from the issue summary (thanks for including that).
Committed c5886a7 and pushed to 9.3.x. Thanks!
Comment #95
andypostThe follow-up is related, needs to get rid of
batch_set()
#2875151: [META] Implement Batch API as a service