Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Sub-issue for meta issue #1880976: [meta] Port examples (including submodules) to D9.4+
Problem/Motivation
D8 all the things!
Proposed resolution
Start with D7 version and figure out how to port ;)
Comment | File | Size | Author |
---|---|---|---|
#9 | interdiff.txt | 9.97 KB | Mile23 |
#9 | 2102643_9.patch | 16.3 KB | Mile23 |
| |||
#8 | 2102643_8.patch | 16.41 KB | Mile23 |
| |||
#7 | interdiff-2102643-4-7.txt | 6.04 KB | John Cook |
#7 | port_batch_example-2102643-7.patch | 16.42 KB | John Cook |
Comments
Comment #1
Mile23This has most of the pieces, with some glue missing.
The state of sessions is in progress so we can't store a number to the session just yet.
Also, I intuit that batches will change radically as well.
But... Here's a framework for this module, and a test that doesn't crash but fails instead. :-)
Comment #2
Mile23Comment #3
joachim CreditAttribution: joachim commentedI'm not sure batches will change -- there is an issue open to change batches to be classes or something like that, and it's not had any activity in ages.
Comment #4
John Cook CreditAttribution: John Cook at CTI Digital commentedI've re-done this patch, removing all the commented out code in the process.
I've used usleep() instead of accessing the database to keep the example as clear as possible and focus on the batch api usage. The database access can still be added in if it is desired.
All the tests now pass.
From the Driesnote at DrupalCon NOLA, all the things should be moved into OOP rather than using functions. So this issue will need to be looked at again when that happens for the Batch API.
Comment #5
John Cook CreditAttribution: John Cook at CTI Digital commentedAdded https://www.drupal.org/node/2401797 as a related issue.
Comment #6
Mile23Thanks.
Big +1 on #2401797: Introduce a batch builder class to make the batch API easier to use I hope that gets in soon.
Whitespace error.
Also, if you install phpcs in your drupal root and then run it under examples, you see these coding standards errors:
Comment #7
John Cook CreditAttribution: John Cook at CTI Digital commentedI've fixed the problems from phpcs.
Comment #8
Mile23Still waiting on #2401797: Introduce a batch builder class to make the batch API easier to use
Or we can commit this and then add a follow-up to change the API. Let's do the latter.
The patch no longer applies, so I'm uploading a reroll.
Comment #9
Mile23Some CS fixes, moved the test to Functional.
Comment #11
Mile23Committed and pushed. Thanks folks!
And here's the follow-up: #2917758: Update batch example to reflect new API (8.6.0)
Comment #12
John Cook CreditAttribution: John Cook commentedThis will need to be re-visited after #2401797: Introduce a batch builder class to make the batch API easier to use and #2875151: [META] Implement Batch API as a service are committed.
Comment #13
Torenware CreditAttribution: Torenware as a volunteer commented@John Cook: yeah, Core is a moving target. When it lands, we'll migrate it. RE those patches: I assume this is a higher level API for batch, and that the current D8 API will be maintained for BC. Once the new stuff lands, we'll want to add to the example I'm sure.