This is issue to keep information about support for batch operations in 6.x at one place.

Comments

meba’s picture

Status: Active » Needs work
StatusFileSize
new2.58 KB

This patch is adding support for latest batch operations (batch_7.patch) (apply to HEAD version of autolocale).

It works smoothly when importing through "import interface translations".

TODO
- TEST IT
- Figure out how $results work and implement it for displaying count of operations made
- Implement importing when enabling modules. (Do anybody know how we stand with the new hook after enabling and disabling a module?)
- Test it when installing Drupal.

yched’s picture

About $return :
actually you can put your stuff in the $result array whichever way you see fit - it's yours.
But I changed the syntax of batched operations since the earlier versions of the batch patch.
They now receive a 'batch context' array as a last param, that gathers results along with other info (mainly used for multi-pass operations)

function my_batch_op($your_arg_1, ..., $your_arg_n, &$context) {
  ... 
  // results are in $context['results']
  $context['results'][] = whatever;
}

The last batch patch contains more detailed phpdoc about that.

yched’s picture

PS : i tested batching stuff inside _enable / _disable hooks, it works perfectly - when triggered by admin/build/modules form submit.
install script being (AFAICT) out of the regular FAPI form processing, having this work at install time probably requires some work on install.php to make it batch-aware (as I did on update.php). Being absolutely unfamiliar with this area, I did not venture there...

meba’s picture

How did you implement the enable/disable stuff? I have a patch doing batch_set() in form_alter for modules but it doesn't work for me, i don't know why yet.

meba’s picture

StatusFileSize
new4.52 KB

Attaching a new patch, doing the same as before, but now with support for enable/disable modules - which DOESN'T work right now. My batch_set() is triggered, but doesn't run operations. I think i need some parameter to the batch...Yched, can you help?

yched’s picture

Batches can't be added or processed in form_alter : that's still form building time.
Batches come into play at form _submitting_ time : the natural place for a batch_set() is during a form_submit callback.

Your form_alter should add a new _submit callback to the form - then declare the batches in this _submit callback.

dries’s picture

Lot's of TODOs in the code ...

Small detail: incorrect use of t(). You'll want to turn that $file into a %file.

drupal_set_message(t("Importing $filepath"));
meba’s picture

StatusFileSize
new4.52 KB

Fixed most of the TODOs, batch after enabling modules still in the works.
Fixed drupal_set_message. Added &$context.

A question:
is $form['#skip_duplicate_check'] = TRUE; required? If i remove it, importing does not work after one import...

yched’s picture

Duplicate submission check works this way :
if the form you submit is the same, with same form values, than the last form the same user submitted, then it's considered a 'duplicate' submission, and the form is not processed.
$form['#skip_duplicate_check'] = TRUE; is therefore recommended for 'little' forms that are likely to be submitted with the same values multiple times, and / or when you develop / debug your forms...

That being said, I _think_ this area might change a little / a lot when the FAPI3 patch lands.

meba’s picture

StatusFileSize
new5.49 KB

Rerolling against HEAD - fixed new paths for locale patch that had been committed yesterday

meba’s picture

StatusFileSize
new8.45 KB

This patch adds needed support for importing locales during installation. Just some moved code and added function

gábor hojtsy’s picture

Status: Needs work » Fixed

Comitted your patch to autolocale module with the following modifications:

- removed @ before include_once in .install file
- removed function_exists() call before include_once, because include_once itself ensures that
- added a TODO note to language addition
- added a proper path prefix value to language addition
- fixed some comments

Anonymous’s picture

Status: Fixed » Closed (fixed)