Wednesday, June 28, 2017 05:09 pm EDT

Batch API

Bri's picture

Example of Using the D7 Batch API to Process Changes to Entities From a Select Query

The other day I decided that I needed to figure out how to use the Batch API. I have had a number of times where I needed to "fix" a bunch of nodes on a site. These are usually one time fixes such as adding a new field to the user object and needing a default value to be set for all the previous users. In most cases I would just create a standard menu callback and let it process. If it was too much to do in a single page request, I would change the query to limit the results and run it multiple times. I knew the Batch API was a better choice, but I hadn't taken the time to figure it out.

Syndicate content