Unverified Commit 9ade85c2 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2969262 by bkosborne, FeyP, BlacKICEUA, dawehner, joelpittet: PHP 7.2:...

Issue #2969262 by bkosborne, FeyP, BlacKICEUA, dawehner, joelpittet: PHP 7.2: Warning: count(): Parameter must be an array or an object that implements Countable n Drupal\views\Plugin\views\argument_validator\Entity->validateEntity()

(cherry picked from commit 73b8d101)
parent 492fd1e3
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -171,8 +171,16 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
   */
  public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = []) {
    // Filter out unused options so we don't store giant unnecessary arrays.
    // Note that the bundles form option doesn't appear on the form if the
    // entity type doesn't support bundles, so the option may not be set.
    if (!empty($options['bundles'])) {
      $options['bundles'] = array_filter($options['bundles']);
    }
    else {
      // Set bundles back to its default empty value.
      $options['bundles'] = [];
    }
  }

  /**
   * {@inheritdoc}
@@ -223,7 +231,7 @@ protected function validateEntity(EntityInterface $entity) {
    }
    // If restricted by bundle.
    $bundles = $this->options['bundles'];
    if (count($bundles) && empty($bundles[$entity->bundle()])) {
    if (!empty($bundles) && empty($bundles[$entity->bundle()])) {
      return FALSE;
    }

+6 −0
Original line number Diff line number Diff line
@@ -176,6 +176,12 @@ public function testValidateArgumentBundle() {

    $this->assertTrue($this->argumentValidator->validateArgument(1));
    $this->assertFalse($this->argumentValidator->validateArgument(2));

    $options['bundles'] = NULL;
    $this->argumentValidator->init($this->executable, $this->display, $options);

    $this->assertTrue($this->argumentValidator->validateArgument(1));
    $this->assertTrue($this->argumentValidator->validateArgument(2));
  }

  /**