- Issue created by @RichardDavies
- πΊπΈUnited States swirt FloridaThank you for reporting this. It looks like the same issue that is described here https://www.jeffgeerling.com/blog/2019/rendering-twig-templates-programm... The twig engine is not loaded during VBO. Seems like adding the twig service as avia dependency injection is the right way to go and might solve this edge case. 
- πΊπΈUnited States RichardDavies Portland, OregonFYI I was able to create a temporary workaround by modifying my code as follows: // Load the Twig theme engine so govdelivery_bulletins can use twig_render_template() when called from a VBO action. include_once \Drupal::root() . '/core/themes/engines/twig/twig.engine'; $twig = \Drupal::service('twig'); $twig_debug = $twig->isDebug(); if ($twig_debug) $twig->disableDebug(); \Drupal::service('govdelivery_bulletins.add_bulletin_to_queue')->addToQueueAndReset(); if ($twig_debug) $twig->enableDebug();
- πΊπΈUnited States swirt FloridaInteresting. I will push up a MR in a little while. But I will need you to tell me if solves the problem. 
- πΊπΈUnited States swirt Florida@richarddavies can you test the patch from this MR with your setup and let me know if it works? 
 https://git.drupalcode.org/project/govdelivery_bulletins/-/merge_request...
- πΊπΈUnited States RichardDavies Portland, OregonI removed my workaround and applied the patch, but it's not working. Now I get this error during normal execution: TypeError: Drupal\govdelivery_bulletins\Service\AddBulletinToQueue::__construct(): Argument #1 ($queue_factory) must be of type Drupal\Core\Queue\QueueFactoryInterface, Drupal\Core\Queue\QueueFactory given, called in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 in Drupal\govdelivery_bulletins\Service\AddBulletinToQueue->__construct() (line 191 of modules/contrib/govdelivery_bulletins/src/Service/AddBulletinToQueue.php). Drupal\Component\DependencyInjection\Container->createService(Array, 'govdelivery_bulletins.add_bulletin_to_queue') (Line: 179) Drupal\Component\DependencyInjection\Container->get('govdelivery_bulletins.add_bulletin_to_queue') (Line: 197) Drupal::service('govdelivery_bulletins.add_bulletin_to_queue') (Line: 401) ...And I get this error when using my VBO action: ArgumentCountError: Too few arguments to function Drupal\govdelivery_bulletins\Service\AddBulletinToQueue::__construct(), 0 passed in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 and exactly 2 expected in Drupal\govdelivery_bulletins\Service\AddBulletinToQueue->__construct() (line 191 of modules/contrib/govdelivery_bulletins/src/Service/AddBulletinToQueue.php). Drupal\Component\DependencyInjection\Container->createService(Array, 'govdelivery_bulletins.add_bulletin_to_queue') (Line: 179) Drupal\Component\DependencyInjection\Container->get('govdelivery_bulletins.add_bulletin_to_queue') (Line: 197) Drupal::service('govdelivery_bulletins.add_bulletin_to_queue') (Line: 401) ...
- πΊπΈUnited States swirt FloridaThank you. I see the problem. working on a fix. 
- πΊπΈUnited States swirt FloridaIf you force refresh that patch I think that should solve those errors. And again thank you for testing this out because I do not have a current site using this module. 
- πΊπΈUnited States RichardDavies Portland, OregonUnfortunately, it's still not working. I get this error now during normal execution and VBO action: Fatal error: Could not check compatibility between Drupal\govdelivery_bulletins\Service\AddBulletinToQueue::create(Drupal\govdelivery_bulletins\Service\ContainerInterface $container) and Drupal\Core\DependencyInjection\ContainerInjectionInterface::create(Symfony\Component\DependencyInjection\ContainerInterface $container), because class Drupal\govdelivery_bulletins\Service\ContainerInterface is not available in /app/web/modules/contrib/govdelivery_bulletins/src/Service/AddBulletinToQueue.php on line 200
- πΊπΈUnited States swirt FloridaWoah... never seen that one before. I'll dig into it this evening. 
- πΊπΈUnited States swirt FloridaOk this should do it. 
 One more time please.
- πΊπΈUnited States RichardDavies Portland, OregonIt worked from my VBO action, but I got this error during normal execution: Warning: Undefined variable $queue in /app/web/modules/contrib/govdelivery_bulletins/src/Service/AddBulletinToQueue.php on line 407 The website encountered an unexpected error. Try again later. Error: Call to a member function deleteItem() on null in Drupal\govdelivery_bulletins\Service\AddBulletinToQueue->dedupeQueue() (line 407 of modules/contrib/govdelivery_bulletins/src/Service/AddBulletinToQueue.php). Drupal\govdelivery_bulletins\Service\AddBulletinToQueue->buildXml() (Line: 334) Drupal\govdelivery_bulletins\Service\AddBulletinToQueue->buildBulletinData() (Line: 285) Drupal\govdelivery_bulletins\Service\AddBulletinToQueue->addToQueue(NULL) (Line: 301) Drupal\govdelivery_bulletins\Service\AddBulletinToQueue->addToQueueAndReset() (Line: 417)It looks like you forgot to replace $queuewith$this->queueon lines 407 and 427.
- πΊπΈUnited States swirt FloridaSorry. I missed the two instances of the $queue. 
 I just pushed a fix.
- πΊπΈUnited States RichardDavies Portland, OregonOk, we've got a winner. It now works without error when executed normally and when executed in my VBO action. Looks good! 
- πΊπΈUnited States swirt FloridaAwesome. Thank you for playing "programming blind" with me. :) 
 I 'll get this merged and cut a release in a few minutes.
- πΊπΈUnited States swirt FloridaThis has been released with 8.x-1.12 β 
- πΊπΈUnited States RichardDavies Portland, OregonPerfect, thank you so much for the quick response and fix!