Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23’s picture

Issue summary: View changes
Status: Active » Needs work
FileSize
31.45 KB

This 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. :-)

Mile23’s picture

joachim’s picture

I'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.

John Cook’s picture

Status: Needs work » Needs review
FileSize
16.59 KB

I'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.

John Cook’s picture

Mile23’s picture

Status: Needs review » Needs work

Thanks.

Big +1 on #2401797: Introduce a batch builder class to make the batch API easier to use I hope that gets in soon.

+++ b/batch_example/src/Form/BatchExampleForm.php
@@ -0,0 +1,151 @@
+    drupal_set_message(t('Creating an array of @num operations', array('@num' => $num_operations)));
+  ¶
+    $operations = array();

Whitespace error.

Also, if you install phpcs in your drupal root and then run it under examples, you see these coding standards errors:

$ ../../vendor/bin/phpcs -p -s
..EE........................................................  60 / 127 (47%)
............................................................ 120 / 127 (94%)
.......


FILE: ...al8/modules/examples/batch_example/src/Form/BatchExampleForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 2 | ERROR | [x] Namespaced classes, interfaces and traits should not
   |       |     begin with a file doc comment
   |       |     (Drupal.Commenting.FileComment.NamespaceNoFileDoc)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...modules/examples/batch_example/src/Tests/BatchExampleWebTest.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
  3 | ERROR | [x] Namespaced classes, interfaces and traits should not
    |       |     begin with a file doc comment
    |       |     (Drupal.Commenting.FileComment.NamespaceNoFileDoc)
 35 | ERROR | [x] Inline comments must end in full-stops, exclamation
    |       |     marks, colons, question marks, or closing parentheses
    |       |     (Drupal.Commenting.InlineComment.InvalidEndChar)
 40 | ERROR | [x] Inline comments must end in full-stops, exclamation
    |       |     marks, colons, question marks, or closing parentheses
    |       |     (Drupal.Commenting.InlineComment.InvalidEndChar)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 2.54 secs; Memory: 18Mb
John Cook’s picture

I've fixed the problems from phpcs.

Mile23’s picture

Still 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.

Mile23’s picture

Some CS fixes, moved the test to Functional.

  • Mile23 committed 3ed5581 on 8.x-1.x authored by John Cook
    Issue #2102643 by Mile23, John Cook, Kristen Pol: Port batch_example...
Mile23’s picture

Status: Needs review » Fixed
Issue tags: -Needs followup

Committed and pushed. Thanks folks!

And here's the follow-up: #2917758: Update batch example to reflect new API (8.6.0)

John Cook’s picture

Torenware’s picture

@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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.