Questions tagged [batch-operations]

Use it for questions about the core API that allows developers to split a big task in several minor chunks or batches.

Filter by
Sorted by
Tagged with
0 votes
0 answers
23 views

Unable to process Batch actions as Administrator

I'm working with a brand new install of Drupal 10 and am having issues with the administrator account (both the default one created at startup and my own personal account) having 'Access Denied' ...
Joseph Quinn's user avatar
0 votes
0 answers
25 views

How can i exit out of a batch process in Drupal 10 or make the operation as a fail?

In the event of a runtime error on a custom batch process how can i either quit the entire batch process or mark that the process was not able to complete?
blu's user avatar
  • 438
2 votes
2 answers
242 views

Deleting entities using Batch API without a form or user interface

In a custom Drupal 9 module, I need to delete entities using Batch API without a form or user interface. The list of entity IDs are generated and the batch is built in hook_views_post_execute(). When ...
bacteriaman's user avatar
2 votes
0 answers
95 views

How to handle batch operations when the user machine gets into suspended mode?

I'm importing a large dataset into the database using the BatchBuilder in Drupal. It takes more than one and a half hours to complete all the operations in the batch. The process starts with user ...
Abhi Das's user avatar
  • 121
1 vote
0 answers
681 views

batch_set results in TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback

I am trying to set a batch from a confirmation form. When it is submitted, this is the code: $operations = []; $operations[] = [ [UpdateEntity::class, 'execute'], ['field_group'] ]; $batch = ...
Kevin's user avatar
  • 27.8k
2 votes
1 answer
2k views

How do I programmatically add images to a node?

I have a content type to which I added an image field. The database has a custom table with different columns, including the image ID. Previously, I created a batch that writes data from this table to ...
nathan111777's user avatar
1 vote
2 answers
433 views

Batch API drush command running once then shows Solr error

I am trying to create a drush command to run a batch process. When I run the command, the batch runs just once, and I get this error : in Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase-&...
el sparrow's user avatar
1 vote
0 answers
165 views

Why might a batch initiated in hook_install() sometimes not process?

I have two modules, module_alpha and module_beta. Both modules install a database table with hook_schema() which they use to track information about published nodes. Data is logged in the table with ...
sonfd's user avatar
  • 7,911
1 vote
1 answer
844 views

How can I fix "Allowed memory size exhausted" on batch finish?

The batch processed all the items, but instead of showing the finish message, I see the error "Allowed memory size of 536870912 bytes exhausted". When I debug the code, I notice that Drupal ...
Egor Elkin's user avatar
0 votes
0 answers
536 views

Batch Error: Using $this when not in object context, so Can I call batch method in non static way?

The existing code when a form is submitted I execute this batch : /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $node_titles = ['node1', '...
Marwen Amri's user avatar
1 vote
1 answer
706 views

How to know if a batch process is still running?

I have a form with 5 buttons and each button run a different batch, some batch processes take several minutes. I want to block the button if the batch processes is already running, because other user ...
Mauricio's user avatar
  • 117
0 votes
1 answer
296 views

Batch processing possible without redirects?

I'm using the Views Data Export module for exporting Views as .csv. Standard exports work in most cases, but with larger table only batch exports work. The problem with batch exports is that the ...
user1205853's user avatar
0 votes
1 answer
124 views

Why does rest export give bad result when executed in batch?

In a custom module (association), I have two content entities (member and person). A function _export_association() is called at the end of each hook_entity (insert, update, delete) in order to run ...
gbmapo's user avatar
  • 1,066
0 votes
0 answers
36 views

How to make progress_message more accurate?

In the submitForm of MembershipSettings, I run a batch: $operations = []; << some query on an custom entity >> $results = $query->execute(); foreach ($results ...
gbmapo's user avatar
  • 1,066
0 votes
1 answer
292 views

How to display batch progression with default theme of my site?

I just created my first batch using batch API and it seems to work! The progression bar is properly displayed during the execution and it uses administration theme, Seven for my site, which I guess is ...
gbmapo's user avatar
  • 1,066
2 votes
1 answer
82 views

How to resave all user accounts on a schedule?

I want to re-save all user accounts on my site weekly because I wrote some code in hook_user_presave() that I want to update every week. Specifically, my hook_user_presave() code updates the values of ...
Patrick Kenny's user avatar
1 vote
2 answers
579 views

Batch redirect to http instead of https

i'm working on a project and all batch callbacks in http not https so instead of redirecting to https://example.com/batch?id=844&op=start redirect to http://example.com/batch?id=844&op=start, ...
berramou's user avatar
  • 7,185
1 vote
1 answer
353 views

Retain Guzzle Session During Batch Operations

On a Drupal 7 site, I am using the Batch API to perform operations on many entities, one at a time. During a typical operation, the D7 site uses Guzzle to make a POST call to a Drupal 8 site. The D7 ...
tyler.frankenstein's user avatar
0 votes
3 answers
515 views

hook_update_n($sandbox) batch getting executed only once

Following is the code where I'm willing to update the description of the field_meta_tags of all my products using the batch process. It's getting executed & working as expected, but only for the ...
Rishi Kulshreshtha's user avatar
2 votes
1 answer
789 views

How do I create a derivative?

I would like to create a queue derivative, where I can use a single QueueWorker class to process multiple queues, but I am not able to achieve it. Any help would be greatly appreciated. The module ...
miststudent2011's user avatar
1 vote
1 answer
206 views

How do I re-save all users?

I need to re-save about 300 user to initialize geo-coding on their address fields. On /admin/people, I don't see any bulk action that would fit my needs. I have tested the update path-alias but with ...
Volker's user avatar
  • 1,370
2 votes
1 answer
587 views

How to pass parameters by reference to a batch?

I need to process a parameter in a batch function where the result will be kept after the function ends and it should be then passed in the finished function of the same batch. Is there a way to pass ...
NeonBlank's user avatar
  • 167
0 votes
1 answer
217 views

Views data export user role field value missing from exported csv file

I'm using views_data_export to export data from the views displays. I added a Data Export option to the user account list views. When I use the batch in export settings, user role field is missing in ...
batMask's user avatar
  • 380
0 votes
1 answer
371 views

How to display a table with results when a batch is finished

I could setup a nice batch, everything is working well. But when the batch is finished, I would like to display a beautiful table with the computed results. I could do it with the drupal_set_message ...
Baud's user avatar
  • 532
1 vote
1 answer
106 views

Why doesn't the batch process start?

I've created a class that extend the 'FormBase' class to create a form where I can upload a XLSX file to import into custom DB table. To process the import I would use the 'Drupal batch process' to ...
umpire274's user avatar
2 votes
1 answer
365 views

Generate PDF with wkhtmltopdf after batch finished

I would like to generate a pdf with wkhtmltopdf at the end of my batch. I integrate the generation in the callback function but it does not offer me the download of the file This is my finished ...
user71007's user avatar
0 votes
1 answer
826 views

How to handle exceptions in a batch process

I have some special configured content entities in my system which are protected in a pre-delete hook against entity deletion. There is also a batch process (VBO - entity delete) where they can be ...
ssibal's user avatar
  • 3,165
0 votes
2 answers
946 views

Use of batch in REST endpoints

I want to use batch in POST in rest endpoints in Drupal 8, but my batch is not getting progressed. I am creating rest endpoints for my module which will send email to bulk users. So for this purpose I ...
user92338's user avatar
2 votes
1 answer
985 views

Batch API to process millions of records

I need to run Batch API on a huge dataset. Specifically I have a custom table with a lot of rows which I need to iterate over. The batch process works fine using small numbers. When using the full set ...
Chris's user avatar
  • 516
2 votes
1 answer
492 views

Batch API error: ResponseText: {"errors":[{"message":"Not acceptable format: json"}]}

When running a batch process on Drupal 8, the following error is returned: ResponseText: {"errors":[{"message":"Not acceptable format: json"}]} The HTTP response is HTTP POST / 406 I can see the ...
David Thomas's user avatar
  • 21.9k
1 vote
1 answer
947 views

Batch API: What am I doing wrong?

I am trying to import some videos into a 8.0.5 site (yes, I know I should upgrade) I have over 200 videos that neeed to be imported into their own individual node. It seems like a perfect opportunity ...
Jimmyb_1991's user avatar
-2 votes
1 answer
190 views

Is the finished callback mandatory?

I checked the documentation about the callbacks used from the batch API, but I didn't find any information about the finished callback being mandatory or not. Is that callback mandatory or optional?
muraliniceguy97's user avatar
0 votes
1 answer
1k views

Batch API times out when running a single operation

I'm trying to print ~100 nodes worth of content (Performance Plans) out to the private file system using the batch API. My process works perfectly up until about 10 of them and then times out. The ...
Shawn Matthews's user avatar
2 votes
1 answer
1k views

Passing form value into batch process

I have a form that is used to trigger a bulk operation and add a node for each of the currently registered users on the site. This is all working well, but I'd like to pass form data from BulkAddForm....
Shawn Matthews's user avatar
0 votes
0 answers
276 views

How to trigger batch job from the command line

I have a batch job that is triggered as soon as I open a specific url of my site, let's call it "http:\mysite.com\job" The last code of that page is: batch_set($batch); batch_process('/'); I need ...
zephirus's user avatar
  • 377
2 votes
1 answer
895 views

Continuing an interrupted batch

I'm using a batch job in Drupal 8 to scrape pages from another site to import. I'm using httpClient, and I have it wrapped in a try/catch. try { $response = \Drupal::httpClient()->get($parts['...
user1359's user avatar
  • 3,919
0 votes
0 answers
60 views

Is it possible to set time interval between adjacent operations in Batch API?

I need to send several thousands of e-mails via Amazon SES. As it turned out, Amazon SES can send no more that 14 e-mails per second. I can send to it no more than 14 e-mails per second - it's a ...
Yakimkin Roman's user avatar
7 votes
4 answers
10k views

How do I structure the batch API array?

I'm working on a Drupal 8 custom module to scrape pages from a site for migration. Since we're dealing with a large number of pages, I wanted to set up batch processing, to deal with timeouts. I ...
user1359's user avatar
  • 3,919
0 votes
1 answer
509 views

Can't save node using batch

When I'm trying to save a node using batch processing, I'm getting this error: PDOException: in drupal_write_record() (line 7383 of C:\wamp64\www\drupal7\includes\common.inc). Here is my complete ...
Parth Vora's user avatar
-1 votes
1 answer
451 views

Passing important data to batch operation

I can't seem to pass any info to the 'finished' function of this batch operation. Everything works in terms of data getting saved correctly but I get the following error message due to the 'finished' ...
Frank's user avatar
  • 1
1 vote
3 answers
3k views

How to write big updation code using Batch API?

I am writing a script to update all website registered user's Username & Email address. I have more then 5000+ users in my website which causes PHP execution time out error. So I tried to ...
Pankaj Sachdeva's user avatar
0 votes
1 answer
2k views

Batch API timeout during initialization

I'm creating a module to batch import/update nodes in Drupal 7 based on input files that can be XML or other formats. Worst case scenario is they are like ~10-20MB and can contain 10-20k entries. ...
NoRandom's user avatar
1 vote
1 answer
356 views

Why won't my batch finish?

I have setup a Batch work which looks the following (dump at run time). The method called for each batch is a public static method, so that is not a problem. All operations performs perfectly, my ...
jchatard's user avatar
  • 131
4 votes
3 answers
9k views

How can execute batch api over cron jobs

I am working on Drupal 8 and batch API. I created the batch api calling importingmatch and it should automatically importing every 1 hour. My solution is use Drush for make it works without the ...
Diep Tang's user avatar
  • 185
2 votes
1 answer
832 views

How to know how many elements are processed in the finish callback?

I followed Smack My Batch Up : Batch Processing In Drupal 8 article to create a batch job and all works fine. But in the finish callback I can't get the total number of processed elements. This is my ...
Adrian Cid Almaguer's user avatar
9 votes
2 answers
4k views

How do you do a redirect after a batch job?

I'm working on setting up a batch process in Drupal 8 that will gather a bunch of remote information for a collection of entities, cache it, and create a list of the results on its own page. The batch ...
acrosman's user avatar
  • 2,728
0 votes
2 answers
615 views

What's the correct way of referencing a method in a controller for running through batch processing?

I have a set of batch operations with: foreach ($urls as $url) { $test_sites[] = array('\Drupal\my_module\Controller\BatchTestSite::TestSite', $url); } When I run it I get the following: ...
digital's user avatar
  • 3,228
5 votes
0 answers
221 views

Is it possible to have a batch job run in a modal

I created a form that on submit it creates a CSV file via batch API. It works perfectly when submitting the form regularly but can't get it to work from a Ctools modal. Could it be that it just isn't ...
albertski's user avatar
  • 3,457
0 votes
1 answer
183 views

How do I show a message about the currently executed operation?

I have created a batch, and it's working, but I want to control the messaging a little better. I would like to give the user some feedback about the currently executing operation, other than just ...
Scott Joudry's user avatar
  • 4,193
8 votes
3 answers
11k views

Documentation or Tutorial on using Batch or Queue Services API Programmatically [closed]

I am working on importing content into my drupal 8 website from an external API that returns XML data. The calls to the API take a long time to process. When I make too many queries at once it takes ...
Hershy's user avatar
  • 191