Duplicated condition

Created on 15 October 2019, about 5 years ago
Updated 2 February 2024, 10 months ago

Hi,

I've submitted a patch https://www.drupal.org/node/3053439 which was committed but resulted in a duplicated condition of the same type.

    if ($view->execute()) {

      /** @var \Drupal\Core\Render\RendererInterface $renderer */
      $renderer = \Drupal::service('renderer');

      /** @var \Drupal\views\ResultRow $resultRow */
      $view_result = $view->result;
      $values      = [];

      foreach ($view_result as $key => $resultRow) {
        if ($view_fields == TRUE) {
          // Inner field array
          $inner_values = [];
          // Building new context for cron
          $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($inner_values, $resultRow, $fields) {
            /** @var \Drupal\views\Plugin\views\field\Field $field */
            foreach ($fields as $field) {
              // Get field ID
              $field_id = $field->field;
              // Get HTML markup
              $html_rended = Markup::create($field->advancedRender($resultRow));
              // Pass extra filter to be sure data is a string
              if(!is_string($html_rended)) {
                $html_rended = $html_rended->__toString();
              }
              // Pass field data to array
              $inner_values[$field_id] = $html_rended;
            }
            return $inner_values;
          });

          $values[$key] = $output;

        } else {

        if ($view_fields == TRUE) {
          // Inner field array
          $inner_values = [];
          // Building new context for cron
          $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($inner_values, $resultRow, $fields) {
            /** @var \Drupal\views\Plugin\views\field\Field $field */
            foreach ($fields as $field) {
              // Get field ID
              $field_id = $field->field;
              // Get HTML markup
              $html_rended = Markup::create($field->advancedRender($resultRow));
              // Pass extra filter to be sure data is a string
              if(!is_string($html_rended)) {
                $html_rended = $html_rended->__toString();
              }
              // Pass field data to array
              $inner_values[$field_id] = $html_rended;
            }
            return $inner_values;
          });

          $values[$key] = $output;

        } else {

          /** @var \Drupal\views\Plugin\views\field\Field $field */
          foreach ($fields as $field) {
            $field_id = $field->field;
            $values[$key][$field_id] = $field->getValue($resultRow);
          }
        }
      }
    }

      $variableObject = new VariableObject($variable->id(), $values, $variable->getType());
    }
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom lexsoft00

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024