Commit db5e7aee authored by catch's avatar catch
Browse files

Issue #3520750 by alexpott: Use a transaction PoDatabaseWriter to improve performance

(cherry picked from commit c15eed32)
parent 362cab42
Loading
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -198,10 +198,15 @@ public function writeItem(PoItem $item) {
   * {@inheritdoc}
   */
  public function writeItems(PoReaderInterface $reader, $count = -1) {
    // Processing multiple writes in a transaction is quicker than committing
    // each individual write.
    $transaction = \Drupal::database()->startTransaction();
    $forever = $count == -1;
    while (($count-- > 0 || $forever) && ($item = $reader->readItem())) {
      $this->writeItem($item);
    }
    // Commit the transaction.
    unset($transaction);
  }

  /**