I have a batch process (using batch API) that runs when a user on my site tries to launch a non signed Java applet. The batch process does all the needed codesigning and other things and then redirects the user to the applet when it is finished. This all works well but if the user hits back from the applet page they get this nasty error with the text from my batch_error function.

enter image description here

It seems that this occurs because when you hit back you end up trying to run a batch process that no longer exists. Is there anyway to avoid this?


Here is my function that sets up the batch process:

function batch_codesign($node) {
$batch = array(
   'operations' => array(
        array('batch_codesign_process', array("create_jar_files", $node)),
        array('batch_codesign_process', array("output_new_agentsheets_applet_html", $node)),
    'finished' => 'batch_codesign_finished',
    'title' => t('Codesigning'),
    'init_message' => t('Codesigning ' . $node->title .'.'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('An error has occured while condesigning the project, please try again.'),    
$nid = $node->nid;
  • Can you not do the codesigning and other things beforehand or is the applet being uploaded right then? – Thomas4019 Apr 3 '15 at 22:24
  • Its a somewhat strange use case where we sometimes have 100s of people uploading projects (which contain applets) at the same time but only some small percentage of those projects will be played right away. If we do the codesining with every upload it can cause performance issues and sometimes interfere with uploads because the codesinging takes much longer then the upload. The codesigning is a long process because the applets come from a legacy applicaiton which does not generate the applet in the correct format. We need to jump though many hoops to get the correct manfiest and such. – Mike2012 Apr 3 '15 at 22:38
  • can you not disable their back button on that page via inserting inline js? I know disabling the back button is bad web-fu, but can be ok in some extreme cases, especially if you include a note. – DrCord Apr 6 '15 at 17:16
  • This is a very worthwhile question, as this even occurs for admins doing updates and such if they accidentally use the back button. – DrCord Apr 6 '15 at 17:30
  • 2
    Could you use an AJAX overlay instead of a new page to process the batch? Then when the user hits back they wouldn't go back to the start of the batch, they'd go back to the page before the one in which they uploaded their applet...? – Darvanen Apr 7 '15 at 9:11

Here's a possible solution, however you'll need to alter the menu callback for patch and wrap the default page callback.

Create your hook_menu_alter() and change batch to be your own page callback function, and update the file attribute (unset if in your .module)

  // Default page for batch operations.
    $items['batch'] = array(
      'page callback' => 'system_batch_page',
      'file' => 'system.admin.inc',

Basically your callback can mimic around the default system_batch_page() page callback. From there you can adjust what happens when someone hits an inactive or stale batch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.