Download & Extend

Avoid dynamically loading action files at each hook_init()

Project:Views Bulk Operations (VBO)
Version:6.x-1.x-dev
Component:Core
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:rules

Issue Summary

As reported in #372114: Crash with "Modifying node's taxonomy terms" executing vbo action doesn't work with rules. The problem is that rules caches the action info for better performance - so hook_action_info() isn't invoked before the action is executed. As an affect the includes are not included yet...

>I don't understand the relationship between invoking an action from a rule, and including VBO actions inside the rules.inc file. Does the rules.inc file automatically get loaded when a rule fires?

Yep rules automatically includes the .rules.inc when it evaluates some rules.

Proposed fix:
>What about adding some code directly into .rules.inc that includes the action includes of vbo? So once .rules.inc gets included, it would automatically include the actions includes and everything should work.

Comments

#1

You can include the following snippet in your rules.rules.inc:

<?php
  $files
= file_scan_directory(drupal_get_path('module', 'views_bulk_operations'), '(.*).action.inc$');
  if (
$files) foreach ($files as $file) {
    require_once(
$file->filename);
  }
?>

or I can put that in my own implementation of hook_init(). Which do you prefer?

#2

Status:active» fixed

I went ahead and included the code above in VBO's hook_init(). This is better because it will let all modules that deal with actions use the VBO ones.

#3

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#4

Title:Using vbo actions with rules» Using vbo actions with rules (file_scan_directory() is expensive)
Component:Code» Core
Status:closed (fixed)» needs review

I'm doing some work profiling a Drupal 6 site, and this file_scan_directory() took around 45-50% of the total request against xmlrpc.php.

Since this list of files will change rarely, here's a patch that hard codes the list in views_bulk_operations_init() rather than using file_scan_directory().

I didn't include it in the patch, but is this only an issue with rules? If it is then should it use a module_exists() as well?

AttachmentSize
vbo_383852.patch 1.07 KB

#5

Title:Using vbo actions with rules (file_scan_directory() is expensive)» Using VBO actions with Rules
Status:needs review» fixed

Thanks for the analysis. I committed a slightly different fix based on the same idea.

I'd be grateful if you could run your same test again to see if the performance has improved.

#6

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#7

Status:closed (fixed)» needs work

This patch is broken - the wrong variable name is referenced

#8

Status:needs work» closed (fixed)

This patch was not used as is.

#9

Title:Using VBO actions with Rules» Avoid dynamically loading action files at each hook_init()

#10

Yes this patch was broken but by the time I'd re-rolled infojunkie had committed a different patch (since another function was doing a similar thing, and without the variable mis-match). In case anyone reaches here again, here's the actual diff that was committed.

AttachmentSize
vbo.patch 2.42 KB

#11