Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Feb 2014 at 08:18 UTC
Updated:
28 Oct 2015 at 19:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jhodgdonIf a Novice contributor wants to work on this... The way I'd suggest to find the Batch API callbacks that need to be marked as implementations would be to look for places in Core that call batch_set(). Which you can do from the batch_set() page on api.drupal.org, and see what functions are being passed in as the callbacks for the operation and for "finished".
And the way to document them is shown at:
https://drupal.org/node/1354#callback-def
Basically, you want to change the documentation block so it just says:
(or callback_batch_operation()). And you can have additional paragraphs in the docs if that makes sense, to explain in particular what this callback function does.
Comment #2
sandykadam commented@jhodgdon Fixed Batch API callbacks documentation block.
Comment #3
joachim commentedLooks good, but is that really all the batch API callbacks we have in D8?
Comment #4
jhodgdonAlso:
You need to remove that line with just a * that will be left at the end of the doc block.
Also, you did a nice job of documenting the 'finished' callback for node_mass_update, but the main operations callback of _node_mass_update_batch_process() also needs to be fixed up.
As joachim suggested in #3, I think there are probably additional examples in Core that also need to be documented. Good start though!
Comment #5
anksy commentedComment #6
sandykadam commented@jhodgdon Fixed the comment.
@joachim I searched the D8 core files but was not able to find callbacks which are defined in https://api.drupal.org/api/drupal/core%21includes%21module.inc/group/cal... this is what issue title says, there are other callbacks which we can create separate issues to cover them.
Comment #7
sandykadam commentedComment #8
jhodgdon@sandykadam: The point of this issue is that when batch_set() is called, you pass in the names of "operations" and optionally "finished" callback functions. In a separate issue, we documented a callback function template for callback_batch_operations() and callback_batch_finished(), which are listed in https://api.drupal.org/api/drupal/core!includes!module.inc/group/callbac... -- and in this issue, we need to find where batch_set() is being called, figure out which functions are being used as those callback functions, and change their documentation so it matches the standards cited above.
This patch addresses just a couple of places in Core, and there are many more, so it's not done yet. The existing docs look good though -- we just need a bigger patch that does this for more functions. Thanks!
Comment #9
elgordogrande commentedFollowing the original instructions by searching for "batch_set()", only a half dozen items come up. Changing the search string to be "batch_set(", leaving off the trailing parenthesis, reveals a much larger result set.
Comment #10
elgordogrande commentedUploading patch from Austin sprint for someone else to review. It's my first patch and would really like some feedback.
Comment #11
joachim commentedAs all batch op callbacks have different parameters, I think it would be better to leave the @param specs on each one.
I'm also not sure all the ones you've found are in fact callbacks, though I haven't time to dive into the code right now, sorry!
Lastly, remember to check for stray whitespace. Most text editors have an option or a command to trim this automatically.
Comment #12
joachim commentedAh yes, I thought as much. locale_translate_batch_build() isn't a batch callback, but a helper for building a batch array. Ditto locale_config_batch_build().
What we're looking for is function names that get put into the 'operations' array in the data given to batch_set(). So for example:
There's a little unpicking to do in the code above; the batch operation callback is 'locale_config_batch_refresh_name'.
Comment #13
jhodgdonThe best way to find these is probably to look at the places that call batch_set() and see what they are passing in, not by using grep.
Comment #14
elgordogrande commentedHere is another attempt at a patch to address the concerns mentioned previously.
Comment #15
LinL commentedSetting to "Needs review" so the testbot can do its thing.
Comment #16
jhodgdonThanks! I have checked this patch carefully, to make sure the functions are correctly marked, and it is mostly right.
A few small things to fix:
a) In most of the patch, you did a great job of adding the new "Implements ... " line and keeping the existing documentation. But:
We lost documentation here on what this function does. Can you add a new line (after a blank line) that will still tell us that this function installs modules in batches?
b)
locale_translate_batch_import() -- I don't think we should mark this as a batch callback only, because it is also directly called in code. So let's just leave this one as it is.
c) typo:
finisherd -> finished
But... This function also has a direct call, so I think we should not document it as a batch callback. So again, let's leave it as it is.
d) locale_config_batch_refresh_name():
Last line here is not quite right. It performs configuration translation *refresh*. It doesn't do translation.
e) See (b) and (c) - also applies to locale_config_batch_finished().
f)
In both of these, we lost the information that it is being called from node_access_rebuild().
g) The two changes in form.api.php -- those were where the callbacks were defined! We do not want them to be changed.
h) Lost information here:
i)
Documentation line at end needs to end in ".".
j) And in user.module, again lost information:
Comment #17
joachim commented> But... This function also has a direct call, so I think we should not document it as a batch callback. So again, let's leave it as it is.
I'd say it's a batch callback. Just happens that another batch finished callback makes use of it.
Comment #18
jhodgdonOK, I can live with that. :)
We still need to make sure we don't lose documentation when we convert the docs headers of these functions.
Comment #19
jhodgdonOh. One thing I thought of last night and forgot to add here:
When you are changing a function docs header to now say "Implements callback_batch_finished()." as its first line (or the other callback), you can take out the @param and @return documentation below, because the idea is that the callback documents this.
However, if the @param/@return has something in it that is specific to this particular callback (as opposed to the generic batch callback param/return docs), you can leave it in.
Comment #20
joachim commentedThat raises a question that I found myself faced with this afternoon in fact, when I was documenting a callback_batch_operation() in a custom module in a project:
Suppose we have:
This should have @params for $foo and $bar because they're not documented anywhere else. But should we omit the @param for $context, because it's standard?
Comment #21
jhodgdonGood question. I personally think having an incomplete list of @param statements is a bit odd, so I think I would put it in. But could go either way.
Comment #22
hussainwebI think that if we are at all listing @param, then we should document all the parameters, even if we are saying the same thing as the callback documentation. Even if the parsers support mixing the parameters, I think it is still useful to have it in the source code for someone who is going to refer the files themselves.
I found some other places where this can be documented. I will look over all instances and work on the patch tomorrow. Assigning this issue to myself.
Comment #23
cleaver commentedI rerolled the patch for latest HEAD and added most of the edits from #16. I omitted any edits that would remove information (callbacks that also have direct calls and callbacks that have documented @params).
Comment #24
Eda commentedComment #25
Eda commentedStill losing information in these 3 places.
Comment #26
cleaver commentedI don't see the harm in adding these lines back in. It makes the comment a bit clearer.
I also cleaned up a few whitespace problems.
Comment #27
jhodgdonLooking pretty close, thanks!
A few more things still to fix:
a) We've still lost some information:
b) Missing . at end of comment:
c) Lost information:
Lost information that it's for the "authorized install batch".
The rest looks good to me! Almost there!
Comment #28
cleaver commentedThanks for the quick review. I applied the changes from #27.
Comment #29
jhodgdonGreat, looks good now!
Comment #30
webchickMuch clearer now. Great work!
Committed and pushed to 8.0.x. Thanks!
Marking for backport.
Comment #32
zopa commentedhi - trying my hand at backporting to D7
I wasn't sure about how to include in the documentation block in conditional cases where batch_set() is called.
thanks!
Comment #33
zopa commentedComment #34
zopa commentedwhoops - sorry - meant to attach to #32
Comment #35
jhodgdonThanks for the patch!
This mostly looks good. The only problem is the placement of the "Implements callback_batch_..." lines. They need to be either at the top of the documentation block, or near the top. Not in the middle of @param sections. Thanks!
Also, in: modules/simpletest/tests/batch_test.callbacks.inc
In this one, I think we can get rid of the other line that was there; same for the next few changes.
And in
I do not believe this is actually a batch callback -- it looks like a form submit handler? Check on the others in that file too -- none of them look like batch callbacks to me.
Comment #36
zopa commentedthanks for the lightening fast review - most of the submit handlers in batch_test.module are calling batch_set() - so still pull them out?
Comment #37
joachim commented> most of the submit handlers in batch_test.module are calling batch_set() - so still pull them out?
Perhaps clarification is needed here. submit handlers are never implementations of batch callbacks, and so their docblocks don't need any changes. However, it's very frequently in a submit callback that you see a call to batch_set(). The functions named in the data passed to batch_set() are the callbacks whose documentation needs changes.
Comment #38
jhodgdonYeah... Just to reword what joachim says...
So. When you call batch_set(), you tell the Drupal batch system what how to process your batch. In that call, you pass in (among other things), the names of some callback functions, the "process" callback and the "finished" callback.
So what we want to happen in this patch is that any functions that are passed into batch_set() as "process" or "finished" callbacks get those lines saying "Implementation of ... " in them.
Functions that *call* batch_set() should not be changed.
Is that clearer?
Comment #39
zopa commentedThanks for the feedback - incorporated #35
Comment #40
jhodgdonWhen you upload a patch, set the issue status to "Needs review". Also, if it's a new patch that updates a previous patch, make an interdiff file. Thanks! (Don't bother for this one though, I've already reviewed the patch.)
So... here are some suggestions:
a)
Again, this is a form submit handler. It is NOT a batch operation callback. Please remove that line of added documentation.
b)
You've inserted three lines between an @param and the description of that parameter. Do not insert it there. Also I do not think this is actually an operations callback at all.
c)
Why are you adding this line? It isn't correct (that isn't how we do @return), and this patch is not about doing this type of thing anyway.
d)
I guess I was wrong about these. We are actually losing information that it is for "batch 0". So probably we just need to add the new line but not lose the existing lines in this file.
e)
Again I do not think this is actually a batch callback. I think it's a function that calls batch_set(). Same with this one:
I haven't checked everything in this patch... some of the others may not be callbacks either. Please check them again.
Oh here's another one:
Comment #41
cleaver commentedI rerolled the patch for HEAD and cleaned up the comments. I addressed the issues in #40, plus the following changes:
includes/install.core.inc:
install_run_task() is not a batch operation callback - removed
includes/locale.inc:
_locale_batch_language_finished() implements callback_batch_finished() - added
_locale_batch_system_finished() implements callback_batch_finished() - added
_locale_batch_import() implements callback_batch_operation() - added
includes/update.inc:
DrupalUpdateException::update_batch() is not a batch operation callback
update_finished implements callback_batch_finished() - added
modules/node/node.admin.inc:
node_mass_update() sets up the batch but is not a callback - removed
_node_mass_update_batch_finished() is not a menu callback, but it is a callback_batch_finished() - fixed
modules/node/node.module:
node_access_rebuild() sets up the batch but is not a callback - removed
modules/simpletest/simpletest.module:
simpletest_run_tests() sets up the batch but is not a callback - removed
modules/simpletest/tests/batch_test.callbacks.inc:
added descriptive comments for batches 0-5
modules/update/update.authorize.inc:
update_authorize_run_update() sets up the batch but is not a callback - removed
update_authorize_run_install() sets up the batch but is not a callback - removed
update_authorize_update_batch_finished() implements callback_batch_finished() - added
modules/update/update.fetch.inc:
update_fetch_data_batch() implements callback_batch_operation() - added
update_fetch_data_finished() implements callback_batch_finished() - added
modules/update/update.manager.inc:
update_manager_download_batch_finished() implements callback_batch_finished() - added
Comment #42
jhodgdonThanks for the patch! This mostly looks good... A few things to fix:
It looks like
_install_profile_modules_finished() in this file is the "finished" callback for this batch, so that should be added to the patch?
This is the doc block for the update_batch() function. This is NOT a batch operations callback -- it is the function that actually calls batch_set(). So, remove this change.
The other two fixes in update.inc look good though.
This is the docblock for node_access_rebuild(). It's a function that sets up a batch, not a batch operation callback, so remove this change.
Needs blank line between 1st and 2nd line.
Comment #43
cleaver commentedThanks @jhodgdon,
I addressed the issues identified in #42. Should be close now :)
Comment #44
jhodgdonThanks for the new patch!
Looking at the interdiff, I think we still wanted to have the finished callback docs in update.inc from the previous patch. Can you put that back? Everything else in the interdiff looks right. Thanks!
Comment #45
cleaver commentedThanks for the review. I took a closer look at update_finished and it definitely is a finished callback. I added back the callback reference to the docs for that function.
Comment #46
jhodgdonThanks everyone! Looks good now.
Comment #49
David_Rothstein commentedCommitted to 7.x - thanks!