Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
For some of my custom modules, i use VBO merely a selection tool, it would be quite nonsense to rewrite the UI. But then, I need to be able to act on completed operations.
Comment | File | Size | Author |
---|---|---|---|
#33 | vbo_finished_rule_event.patch | 2.32 KB | bluetegu |
vbo_after_hook.patch | 815 bytes | Aron Novak | |
Comments
Comment #1
infojunkieThanks for the initiative. I've been meaning to add this for a while.
I committed this slightly differently, to support VBO_EXECUTION_DIRECT and VBO_EXECUTION_BATCH execution modes. Please review and let me know if it still works as intended for you.
Comment #2
infojunkieOops, committed too soon. I'll issue another patch.
Comment #3
Aron Novakperfect, awesome
Comment #4
Aron Novakhah, just changed the status accidentally
Comment #5
infojunkieReverted the previous commit.
What needs to be done is this: support VBO_EXECUTION_DIRECT and VBO_EXECUTION_BATCH for calling
hook_views_bulk_operations_finish
, possibly by invoking it from within_views_bulk_operations_batch_finished
(which ends up being called in both cases). This just needs the relevant parameters to be accessed inside this function.Comment #6
infojunkieCommitted to dev. Thanks!
Comment #8
bojanz CreditAttribution: bojanz commented7.x-3.x should have this.
Comment #9
bojanz CreditAttribution: bojanz commentedDone.
Comment #11
bojanz CreditAttribution: bojanz commentedIf anyone finds this issue, note that this hook was removed afterwards from 7.x-3.x:
http://drupalcode.org/project/views_bulk_operations.git/commitdiff/f4e6e...
It wasn't actually useful since it got very little data (no entity ids operated on for example). A much better solution for the problem is to write an action that just calls your function. It is just a few extra lines of code and gives you much more data (all loaded entities, etc).
From a performance point of view it is not feasible to have the same amount of data present in the finished callback.
If there is a use case that can work with getting the rows & entities, we can reconsider.
Either that, or store the processed entity ids in the process functions so that the finished callback can pass them along to the hook.
However, that might be too much for Batch API, because I'm guessing the data saved in $context is serialized as well, and serializing another thousand ids might be too much.
Comment #12
bojanz CreditAttribution: bojanz commentedThis is a better status. Could use feedback. What are the exact use cases for this hook?
Comment #13
bojanz CreditAttribution: bojanz commentedNo clever ideas for now, it seems. My #11 (writing a small custom action) still sounds good. Reopen if you have anything to add.
Comment #14
yvmarques CreditAttribution: yvmarques commentedHi,
I've an example that needs to know when VBO finish.
In my example, I've to export a thousand items (user or node) in only one PDF. My idea was to create different files and when VBO will finish I concat all of them, but actually I've not idea how to know when VBO finish or not.
Or somebody has another idea how to do it without that hook ?
Comment #15
bojanz CreditAttribution: bojanz commentedI think a better idea is to create the PDF, then append to it for each entity.
You can see an example of this in the "create archive" action (actions/archive.action.inc) that ships with 7.x-3.x-dev (it uses $context to see the position in the set, like 0/100, 50/100, 100/100). In any case, the data in $context ($context['progress']['current'], $context['progress']['total']) should be enough to allow you to do what you need.
Comment #16
yvmarques CreditAttribution: yvmarques commentedIts exactly what I want do. Unfortunately, I forgot to tell that is form Drupal 6.x branch. There is also possible ?
Comment #17
bojanz CreditAttribution: bojanz commented6.x has the mentioned hook (hook_views_bulk_operations_finish) so you can just use that.
Comment #18
yvmarques CreditAttribution: yvmarques commentedWell, I didn't understand that you kept the patch for the 6.x branch. Thanks !
-- Yvan
Comment #20
kevin.mcnamee@mailbox.org CreditAttribution: kevin.mcnamee@mailbox.org commentedBut actions are called per object. So I am assuming that the $context contains information about when the last object is being processed so that my function can trigger on that to do any post-processing.
Furthermore, if the user can select between a list of actions to apply to the list of objects, then all of them will have to be implemented as custom actions in order to trigger post-processing. Of course, these can be just wrappers around normal actions which can be called with actions_do.
Something like:
Have I understood correctly?
Cheers,
Kevin
Comment #21
infojunkie@kmcnamee, are you talking about D7?
Comment #22
kevin.mcnamee@mailbox.org CreditAttribution: kevin.mcnamee@mailbox.org commentedNo, D6.
/Kevin
Comment #23
infojunkieIn D6, the hook
hook_views_bulk_operations_finish($operation, $params, $results)
is called.Comment #24
kevin.mcnamee@mailbox.org CreditAttribution: kevin.mcnamee@mailbox.org commentedSorry, a bit slow this morning. Yes, the finish hook is available in D6 and I am successfully using it. My observation in #20, is that without the hook, the developer must do a lot more work. In other words, I am arguing for reinstating the hook in D7, assuming my analysis is correct.
/Kevin
Comment #26
kevin.mcnamee@mailbox.org CreditAttribution: kevin.mcnamee@mailbox.org commentedComment #27
bojanz CreditAttribution: bojanz commentedThe changes I plan to make in #1176794: Improve Batch Performance (storing the ids in a queue) make it even more impossible for the finished hook to get the entity ids.
So you could only get the operation name and a few params, which is useless.
Hence, this is a "won't fix" for D7.
Comment #28
hansfn CreditAttribution: hansfn commentedA related question: I need to do something when my action is called on the last row. I don't see how I can use hook_views_bulk_operations_finish. Is there any work-around? I know this is trivial in the D7 version since it has the $context['progress'] array.
PS! Is hook_views_bulk_operations_finish documented at all?
Comment #29
hansfn CreditAttribution: hansfn commentedI'm reopening this so it hopefully gets some attention. (Sorry if I'm violating a guideline.)
Comment #30
agungsuyono CreditAttribution: agungsuyono commentedIf I need nodes/nids selected to be passed to 'hook_views_bulk_operations_finish', how to I do that? My case is I want to select some nodes using VBO and then those nodes to be printed out in HTML format after submit, using .tpl.php defined in 'hook_theme'.
Thanks for the help,
Agung
Comment #31
xatoo CreditAttribution: xatoo commentedI'd wish to give this issue a little kick. Is there already an alternative solution for D7?
@bojanz: I don't agree with you that just getting the operation name with some extra parameters is useless. In some cases the only thing what you wish to do is clear/rebuild some kind of cache. You don't need a list of processed items for that. Isn't there any chance on a hook_views_bulk_operations_finish in D7?
Comment #32
hansfn CreditAttribution: hansfn commentedThis is fixed for D7 - see comment #15.
Comment #33
bluetegu CreditAttribution: bluetegu commentedI wasn't aware of the solution described in #15 and took a different approach of firing up a 'finish' rule event. It doesn't work for queue processing though. FWIW attached is the patch.
Comment #34
kenorb CreditAttribution: kenorb commentedFixed as per #15. Drupal 6 is no longer supported.
Comment #36
Bedstvie CreditAttribution: Bedstvie commentedYou can use hook_batch_alter