As noted in the comments in the Batch API example (https://api.drupal.org/api/drupal/includes!form.inc/group/batch/7), the finished callback name in the batch definition (my_finished_callback) does not match the function declaration (batch_test_finished).

see comment: https://api.drupal.org/comment/32503#comment-32503

Abbreviated beta evaluation: This is an unfrozen docs fix (only changes an example in API docs).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cleaver’s picture

Status: Active » Needs review
FileSize
518 bytes

Patch changes the callback in the batch definition to the actual function name:

<?php
$batch = array(
  'title' => t('Exporting'),
  'operations' => array(
    array('my_function_1', array($account->id(), 'story')),
    array('my_function_2', array()),
  ),
  'finished' => 'batch_test_finished',
  'file' => 'path_to_file_containing_myfunctions',
);
?>

IE: my_finished_callback -> batch_test_finished

cleaver’s picture

Issue tags: +LatinAmerica2015
jhodgdon’s picture

Status: Needs review » Needs work

Thanks! But I think the better fix, to be more consistent with the rest of the example, would be to change the function name in the code below to my_finished_callback.

cleaver’s picture

Status: Needs work » Needs review
FileSize
588 bytes

Makes sense... the other functions start with "my_". I'm flipping it around.

Status: Needs review » Needs work

The last submitted patch, 4: 2425325-4-cleaver-batch-api-finished-callback-document.patch, failed testing.

Status: Needs work » Needs review
jhodgdon’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Documentation is not frozen during beta. Committed 2bbeb8f and pushed to 8.0.x. Thanks!

  • alexpott committed 2bbeb8f on 8.0.x
    Issue #2425325 by cleaver: Batch API example code has wrong finished...
David_Rothstein’s picture

Version: 8.0.x-dev » 7.x-dev
Status: Fixed » Patch (to be ported)
Issue tags: +Needs backport to D7

Looks like this should be backported?

cleaver’s picture

cleaver’s picture

Status: Patch (to be ported) » Needs review
David_Rothstein’s picture

Status: Needs review » Needs work

Thanks, but isn't that replacing the wrong thing? I think we want it to replace "batch_test_finished", just like the Drupal 8 patch.

JacobSanford’s picture

Status: Needs work » Needs review
FileSize
566 bytes
620 bytes

Thanks for review! Requested changes.

  • jhodgdon committed 98bd112 on 7.x
    Issue #2425325 by cleaver, JacobSanford: Batch API example code has...
jhodgdon’s picture

Status: Needs review » Fixed

Committed correct backport to D7. Thanks again everyone!

Status: Fixed » Closed (fixed)

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