1. It's not clear where the params for the finished callback batch_example_finished come from:

function batch_example_finished($success, $results, $operations) {

Op 1 has this:

  // Store some result for post-processing in the finished callback.
  $context['results'][] = $node->nid . ' : ' . check_plain($node->title);

Is that it? If so, there's also surely a bug in the code as op 2 doesn't put anything into the results key.

2. Where does the progress message get its placeholders from?

    'progress_message' => t('Processed @current out of @total.'),

I can't see anything being put into $context that looks remotely like either of those!

CommentFileSizeAuthor
#1 1063302-1-7.x.patch3.07 KBBrockBoland

Comments

BrockBoland’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new3.07 KB

The attached patch adds some explanatory comments for the 7.x branch. I'm not sure if Examples follows a backport policy like Drupal core, but I'll wait for some feedback on this one before backporting for 6.x.

joachim’s picture

Status: Needs review » Needs work

Looks good.

Could batch_example_finished() get its @params documented too? I can't find anything about these at all.

mile23’s picture

Title: further mysteries of batchAPI... » Inline docs for BatchAPI
Status: Needs work » Closed (fixed)

Nice addition!

Stylistically, it's better to have inline comments inside the function, rather than docblocks, so I converted it.

Committed: http://drupalcode.org/project/examples.git/commitdiff/4a89d812be35c63c33...

Thanks!

@joachim: You can see the @params being defined in _batch_process(), and they're listed in this change.