In core/modules/locale/locale.batch.inc we have the $options argument optional, but it comes before $context which is a mandatory argument.

We should make $options so it is not optional.

function locale_translation_batch_status_check($project, $langcode, array $options = array(), &$context) {

This was discussed while making updates to the documentation in the locale module:

https://www.drupal.org/node/2288793#comment-9259653

Comments

jamesdixon’s picture

I should note the documentation block for this function should be changed to reflect the new order of arguments.

alexpott’s picture

Status: Active » Closed (won't fix)

We can't do this the context argument is added by the batch system which is why it is impossible for options to optional.

alexpott’s picture

More information: locale_translation_batch_status_check is used as a batch operation in _locale_translation_batch_status_operations - batch operations have the batch context pass in as a the final agrument in _batch_process() - specifically:

      call_user_func_array($callback, array_merge($args, array(&$batch_context)));

That array_merge() means that batch operations can not have optional arguments.

jamesdixon’s picture

Title: Need to change the order of arguments in function locale_translation_batch_status_check so the options argument can be optional » function locale_translation_batch_status_check has an optional argument before a mandatory argument in the function definition
Issue summary: View changes
Status: Closed (won't fix) » Needs work

@alexpott: You're right, sorry I misunderstood your comment in the documentation issue. I've renamed this issue title and changed the summary to reflect your recommendation.

alexpott’s picture

Perhaps we can then just fix this in the other issue?

jamesdixon’s picture

Status: Needs work » Closed (won't fix)

Sounds good, I'll fix it up in the other issue and change the other issues component.