Skip to content
Snippets Groups Projects

Documentation updates

Open David Pickett requested to merge issue/codit_batch_operations-3466421:1.0.x into 1.0.x
3 files
+ 128
103
Compare changes
  • Side-by-side
  • Inline
Files
3
docs/faq.md 0 → 100644
+ 51
0
# Frequently Asked Questions
- [How do I run my script and have it keep going if there are errors?](#how-do-i-run-my-script-and-have-it-keep-going-if-there-are-errors)
- [How do I run my script with Drush?](#how-do-i-run-my-script-with-drush)
- [Can I list all the Batch Operations with Drush?](#can-i-list-all-the-batch-operations-with-drush)
- [When trying to run script, I get an error telling me a script is already running, but one should not be. How do I fix this?](#when-trying-to-run-script-i-get-an-error-telling-me-a-script-is-already-running-but-one-should-not-be-how-do-i-fix-this)
- [How do I have the script run as someone other than the default user?](#how-do-i-have-the-script-run-as-someone-other-than-the-default-user)
- [How do I delete all the Batch Operation Logs so that I can uninstall the module?](#how-do-i-delete-all-the-batch-operation-logs-so-that-i-can-uninstall-the-module)
- [Why do the cron time settings say 'after' instead of 'at'?](#why-do-the-cron-time-settings-say-after-instead-of-at)
- [How do I have a BatchOperation only have the option to run once?](#how-do-i-have-a-batchoperation-only-have-the-option-to-run-once)
- [I defined my BatchOperation to only run once, but I need it to run again. How do I force it to run again?](#i-defined-my-batchoperation-to-only-run-once-but-i-need-it-to-run-again-how-do-i-force-it-to-run-again)
- [How do I see all the built-in test BatchOperations in the UI?](#how-do-i-see-all-the-built-in-test-batchoperations-in-the-ui)
- [Are there supporting functions I can use within processOne()?](#are-there-supporting-functions-i-can-use-within-processone)
## How do I run my script and have it keep going if there are errors?
The third argument in the `run()` method is optional. Set it to `TRUE` if you want your script to skip items with errors.
## How do I run my script with Drush?
The Drush command is `drush codit-batch-operations:run {script class name}` it has an optional flag `--allow-skip`. The flag allows you to skip an errors or failures that occur, leaving the flag off, makes it fail on the first error or exception.
## Can I list all the Batch Operations with Drush?
You can list all available Batch Operations with `drush codit-batch-operations:list` Use the option `--tests` to also see the test Batch Operations.
## When trying to run script, I get an error telling me a script is already running, but one should not be. How do I fix this?
First, check with your team to make sure someone else is not running a Batch Operation script.
If they confirm that nothing should be running, you can reset the flag by using
`drush codit-batch-operations:running --reset` or visit the settings page /admin/config/development/batch_operations/settings
## How do I have the script run as someone other than the default user?
There are two methods to switch users:
1. Call `switchUser(<UID>)` in preRun();
2. If executing in a hook, you can call `switchUser(<UID>)` before calling `run()`.
3. In your `processOne()` method you can call `switchUser(<UID>)`. Only choose this option if you must change users more than once in your processing. Otherwise use option 1.
## How do I delete all the Batch Operation Logs so that I can uninstall the module?
You will find a 'Delete all batch operation logs' link on the settings page.
## Why do the cron time settings say 'after' instead of 'at'?
Cron timings on cron jobs from this module are evaluated every time cron runs. Due to the settings of your cron, you may have a cron that only runs every 2 hours, so the timings of the cron job can only be tested every 2 hours. If you want your times to be more accurate, set cron to run more often (**warning this can have performance issues**).
## How do I have a BatchOperation only have the option to run once?
If you have a process that would be damaging to have it run more than once, add a `public function getAllowOnlyOneCompleteRun() {return TRUE; }` to your BatchOperation.
## I defined my BatchOperation to only run once, but I need it to run again. How do I force it to run again?
The state of it running before is stored in the BatchOpLog that shows as `Completed`. Delete the BatchOpLog that shows as completed and the BatchOperation will be allowed to run again.
## How do I see all the built-in test BatchOperations in the UI?
The tests are not usually shown in the UI. To see them, go to the setting page and delete the setting for the machine name of the local module where your scripts are stored. The UI will now show the test BatchOperations.
## Are there supporting functions I can use within processOne()?
Yes there are Node and Term related function that can be very helpful. Look in BatchOperationsNodeTrait.php and BatchOperationsVocabularyTrait.php
Loading