Account created on 11 September 2012, over 12 years ago
#

Recent comments

🇩🇪Germany marvin_B8

I have tried the patch purge-2853613-12.patch and it works as expected. I can provide screenshots if this is wanted .

🇩🇪Germany marvin_B8

Looks pretty good so far, I just noticed the following things:

- unset the transaction should not be necessary (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...)
- The logic for the id could be reversed.

So that it looks something like this:

  public function createItemMultiple(array $items) {
    // Wrap these in our own loop so we get the right ID values.
    $ids = [];
    $now = time();
    $transaction = $this->connection->startTransaction();
    try {
      foreach ($items as $data) {
        $id = $this->connection->insert(static::TABLE_NAME)
          ->fields([
            'data' => serialize($data),
            'created' => $now,
          ])->execute();

        if (empty($id)) {
          // This will trigger a rollback of the transaction.
          throw new \Exception('Inserted item did not return an ID');
        }

        $ids[] = (int) $id;
      }
    }
    catch (\Exception $e) {
      $transaction->rollBack();
      return FALSE;
    }

    return $ids;
  }

and If it's a performance problem, we can also think about putting the whole thing in a different queue.

Production build 0.71.5 2024