Can you tell if the nodapia hook (or some kind of hook) is running from batch mode?
I have a Drupal module that makes a soap request in node using hook_nodapi. This is not a big loss in performance for individual savings, but if thousands of nodes are saved in batch mode, this is a big bottleneck.
I would like to perform a different action when the hook is called from batch mode, but cannot see an easy way to tell it.
Does anyone have any ideas?
source to share
You can call batch_get()
and check the result. If it is not empty, you are in batch mode.
(Note: Let's assume Drupal-6 is here)
source to share
If you are referencing a drupal level package using the Batch API , Henrik's suggestion is recommended.
If, however, you are referring to a wrapped batch process, which is more practical for large batches than for websites, you might want to test php_sapi_name () : if return "cli"
is a command line and could be a shell package. Depends on your context.
source to share