- Issue created by @rszrama
- 🇺🇦Ukraine khiminrm
I’ve spent some time to try to implement the suggested fixes.
But with the __destruct() method it doesn’t work in OrderStorage.
I’ve got the error on line if ($this->lockBackend->acquire($lock_id)) { in loadForUpdate() $order_id)Drupal\Core\Database\StatementWrapperIterator::__construct(): Argument #2 ($clientConnection) must be of type object, null given, called in /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php on line 557
Maybe related to https://www.drupal.org/project/drupal/issues/1924166 →
Also I tried to add custom service with needs_destruction tag and with destruct() method and use it inside the OrderStorage class. But it didn’t work also but with another reason - in the desturct() method the variable with the list of the orders was empty, but I saw in debug that the order ID value was added to the array.
Can’t find properly worked solution.
Looks like we need to resave free order so place transition is applied first and only then dispatch the paid order event on second save. But if free order is created programmatically with other than ‘draft' or ‘canceled’ state then resaving the order doesn’t make sense as ‘placed' transition event shouldn’t be dispatched.