Commit 51621190 authored by Marcin Grabias's avatar Marcin Grabias
Browse files

Merged dev.

parents d38f09d8 9242b773
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -305,6 +305,8 @@ class ViewsBulkOperationsActionProcessor implements ViewsBulkOperationsActionPro
      $batch_list = $list;
    }

    // Note: this needs to be set to 0 because otherwise we may lose
    // entity translations from the results.
    $this->view->setItemsPerPage(0);
    $this->view->setCurrentPage(0);
    $this->view->setOffset(0);
@@ -365,25 +367,23 @@ class ViewsBulkOperationsActionProcessor implements ViewsBulkOperationsActionPro
    $this->moduleHandler->invokeAll('views_pre_execute', [$this->view]);
    $this->view->query->execute($this->view);

    // Get entities.
    // Get all the entities in the batch_list from the view.
    // Check language as well as the query will fetch results basing on
    // base ID field for all languages.
    $this->viewDataService->init($this->view, $this->view->getDisplay(), $this->bulkFormData['relationship_id']);

    $result_hits = [];
    foreach ($batch_list as $delta => $item) {
      foreach ($this->view->result as $row_index => $row) {
      // This may return rows for all possible languages.
      // Check if the current language is on the list.
      $found = FALSE;
        if (array_key_exists($row_index, $result_hits)) {
          continue;
        }
        $entity = $this->viewDataService->getEntity($row);
      foreach ($batch_list as $key => $item) {
        if ($row->{$base_field} === $item[0] && $entity->language()->getId() === $item[1]) {
          $result_hits[$row_index] = TRUE;
          $this->queue[] = $entity;
          $found = TRUE;
          unset($batch_list[$key]);
          break;
        }
      }
      if (!$found) {
        unset($this->view->result[$row_index]);
      }
    }

    // Extra processing when executed in a Batch API operation.