- π¨π΄Colombia jedihe
Running VBO 4.2.3, I can confirm batching does work: I was hitting PHP's max memory with a batch size of 20, then I started tweaking the batch size to a lower value until processing ran just fine, all items were correctly processed.
This report may be related to #3227671: VBO batch process seems to be broken after #3167619 β .
- πΊπΈUnited States aaronelborg
I'm not sure if this is the best place to ask this so forgive me if I'm out of place here...
I'm wondering if OP's issue stems from the fact that they're accessing properties within the execute() function from a loaded single entity but performing operations on many items that were referenced by said single entity. My assumption is that the bulk operation is only aware of that single entity. I'm actually running into this issue now and a search found this issue so here I am.
In short, I'd like to get my custom VBO action to access bulk operations messaging/saving operations... but not on the $entity passed to execute. Instead, I need this data to reference the entities referenced from the single $entity passed to execute().
For example, if I'm loading nodes tagged with a certain term and then removing that term from these nodes, how can I access the bulk operations data to do its operations (messaging, count of items, etc) on these nodes? Obviously, they aren't the $entity passed to the execute method so (I'm assuming) that the bulk operations has no knowledge of their existence. What I'm using works but it will time-out occasionally on terms that reference tons of nodes. As it stands, I just re-run it until I actually see the progress bar finish.
I've found very little documentation on this which leads me to believe I might be doing something weird and/or wrong. Thanks for any advice.
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties([ $old_vocab_field => $tid, ]); foreach ($nodes as $node) { // Add tid to node. $node->set($new_vocab_field, $tid); foreach ($node->get($old_vocab_field) as $k => $v) { $target_id = $v->get('entity')->getTargetIdentifier(); if ($target_id == $tid) { // Remove old tid from node. $node->$old_vocab_field->removeItem($k); $node->save(); break; } } }
- π΅π±Poland Graber
@AaronELBorg I think you need to use batch API for your processing and not use VBO but a custom solution. Batch in a batch will not work I think..
- π΅π±Poland Graber
Or differently: create e view that displays what you actually need to process.
- πΊπΈUnited States aaronelborg
@Graber, Yeah as soon as I hit the 'submit' button on my post, I thought "yeah... this could be done by accessing the node ($entity) directly instead". I appreciate your input though. Thanks!