Closed (fixed)
Project:
Views Bulk Operations (VBO)
Version:
7.x-3.x-dev
Component:
Core
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Aug 2011 at 14:01 UTC
Updated:
31 Oct 2016 at 15:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
moonray commentedAnd here's a patch.
If there is a god reason to keep loading the action includes in hook_init, let me know. It should probably be documented in code, at that point.
Comment #2
bojanz commentedWhat we are doing right now is insane, and your patch is almost perfect in fixing it.
There is no need to do the including in hook_init(). Doing it in our implementation of hook_action_info() is enough because that hook is invoked both when an action is executed (by actions_do()) and when actions are listed in VBO / views admin (because views_bulk_operations_operation_action_list() calls actions_list() which invokes hook_action_info).
The only thing I'd add to your patch is caching (indefinitely) the output of file_scan_directory(). Even with the patch it is guaranteed that file_scan_directory() will be invoked once per (vbo / action execution) request, all in order to scan a directory whose list of files doesn't really change. Having to do a cache clear after adding a new action file (which I guess will happen three to four times during the whole D7 cycle) is perfectly fine.
Comment #3
moonray commentedI ran some (admittedly local) speed tests, and DB reading seemed to be slower than reading the file dir. Of course, it's a small dir.
I had written the caching code, but stripped it when I saw that it was slower.
Thoughts?
Comment #4
bojanz commentedI spoke to catch about this. His conclusion:
Hardcoding the list of files > variable_get > cache > file_scan_directory().
And I'm fine with just hardcoding the list in an array at the top of views_bulk_operations_load_includes() (though we might want to rename it to views_bulk_operations_load_actions or views_bulk_operations_load_action_includes), along with a comment explaining the situation.
Comment #5
bojanz commentedSo, how about this? Works on my setup.
Comment #6
bojanz commentedCommitted.
Comment #8
hefox commentedSemi-backport for d6. The functions are a bit different so did what seemed relavent
Comment #9
jonhattanMeasured ~1.4ms less in hook_init
Comment #10
kenorb commentedFixed in 7.x as per #6. Since D6 is no longer supported, therefore backported patch most likely won't be applied anymore.