From 66ae877b0ab9c72deb3430cd5043487a672fda33 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 4 Jan 2016 11:58:51 +0000
Subject: [PATCH] =?UTF-8?q?Issue=20#2605214=20by=20G=C3=A1bor=20Hojtsy,=20?=
 =?UTF-8?q?ChuChuNaKu,=20EclipseGc,=20dawehner:=20Views=20InOperator::getV?=
 =?UTF-8?q?alueOptions()=20children=20do=20not=20return=20values=20like=20?=
 =?UTF-8?q?InOperator::getValueOptions()?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

(cherry picked from commit 1546d71f807a3431e80dedbcdab5302f67bb7e24)
---
 .../comment/src/Plugin/views/filter/NodeComment.php  |  1 +
 core/modules/file/src/Plugin/views/filter/Status.php |  1 +
 .../language/src/Tests/Views/FilterLanguageTest.php  | 12 ++++++++++++
 .../src/Plugin/views/filter/TaxonomyIndexTid.php     |  7 ++++++-
 core/modules/user/src/Plugin/views/filter/Name.php   |  8 ++++++--
 .../user/src/Plugin/views/filter/Permissions.php     |  1 +
 core/modules/user/src/Plugin/views/filter/Roles.php  |  2 ++
 .../src/Tests/Views/HandlerFilterPermissionTest.php  |  1 -
 .../user/src/Tests/Views/HandlerFilterRolesTest.php  |  6 ++++++
 .../src/Tests/Views/HandlerFilterUserNameTest.php    |  2 ++
 .../views/src/Plugin/views/filter/InOperator.php     |  4 ++--
 .../views/src/Plugin/views/filter/LanguageFilter.php |  1 +
 12 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/core/modules/comment/src/Plugin/views/filter/NodeComment.php b/core/modules/comment/src/Plugin/views/filter/NodeComment.php
index a83ec3930fd6..234075289090 100644
--- a/core/modules/comment/src/Plugin/views/filter/NodeComment.php
+++ b/core/modules/comment/src/Plugin/views/filter/NodeComment.php
@@ -25,6 +25,7 @@ public function getValueOptions() {
       CommentItemInterface::CLOSED => $this->t('Closed'),
       CommentItemInterface::OPEN => $this->t('Open'),
     );
+    return $this->valueOptions;
   }
 
 }
diff --git a/core/modules/file/src/Plugin/views/filter/Status.php b/core/modules/file/src/Plugin/views/filter/Status.php
index 5d73454dd66f..7d6db6f26dc0 100644
--- a/core/modules/file/src/Plugin/views/filter/Status.php
+++ b/core/modules/file/src/Plugin/views/filter/Status.php
@@ -22,6 +22,7 @@ public function getValueOptions() {
     if (!isset($this->valueOptions)) {
       $this->valueOptions = _views_file_status();
     }
+    return $this->valueOptions;
   }
 
 }
diff --git a/core/modules/language/src/Tests/Views/FilterLanguageTest.php b/core/modules/language/src/Tests/Views/FilterLanguageTest.php
index 591ad179c2a9..b3cc5d81988b 100644
--- a/core/modules/language/src/Tests/Views/FilterLanguageTest.php
+++ b/core/modules/language/src/Tests/Views/FilterLanguageTest.php
@@ -45,6 +45,18 @@ public function testFilter() {
         'name' => $name,
       ));
       $this->assertIdenticalResultset($view, $expected, array('views_test_data_name' => 'name'));
+
+      $expected = [
+        '***LANGUAGE_site_default***',
+        '***LANGUAGE_language_interface***',
+        '***LANGUAGE_language_content***',
+        'en',
+        'xx-lolspeak',
+        'und',
+        'zxx'
+      ];
+      $this->assertIdentical(array_keys($view->filter['langcode']->getValueOptions()), $expected);
+
       $view->destroy();
     }
   }
diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
index 46b8eb9ac6d7..c660d20ff856 100644
--- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -89,7 +89,12 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
 
   public function hasExtraOptions() { return TRUE; }
 
-  public function getValueOptions() { /* don't overwrite the value options */ }
+  /**
+   * {@inheritdoc}
+   */
+  public function getValueOptions() {
+    return $this->valueOptions;
+  }
 
   protected function defineOptions() {
     $options = parent::defineOptions();
diff --git a/core/modules/user/src/Plugin/views/filter/Name.php b/core/modules/user/src/Plugin/views/filter/Name.php
index a4be2f547f97..0066f712786f 100644
--- a/core/modules/user/src/Plugin/views/filter/Name.php
+++ b/core/modules/user/src/Plugin/views/filter/Name.php
@@ -101,8 +101,12 @@ protected function valueSubmit($form, FormStateInterface $form_state) {
     // prevent array filter from removing our anonymous user.
   }
 
-  // Override to do nothing.
-  public function getValueOptions() { }
+/**
+ * {@inheritdoc}
+ */
+  public function getValueOptions() {
+    return $this->valueOptions;
+  }
 
   public function adminSummary() {
     // set up $this->valueOptions for the parent summary
diff --git a/core/modules/user/src/Plugin/views/filter/Permissions.php b/core/modules/user/src/Plugin/views/filter/Permissions.php
index c113b2eee39e..6cbb703970cd 100644
--- a/core/modules/user/src/Plugin/views/filter/Permissions.php
+++ b/core/modules/user/src/Plugin/views/filter/Permissions.php
@@ -78,6 +78,7 @@ public function getValueOptions() {
         $display_name = $this->moduleHandler->getName($provider);
         $this->valueOptions[$display_name][$perm] = Html::escape(strip_tags($perm_item['title']));
       }
+      return $this->valueOptions;
     }
     else {
       return $this->valueOptions;
diff --git a/core/modules/user/src/Plugin/views/filter/Roles.php b/core/modules/user/src/Plugin/views/filter/Roles.php
index bcae6f94cdc2..e017c647ab29 100644
--- a/core/modules/user/src/Plugin/views/filter/Roles.php
+++ b/core/modules/user/src/Plugin/views/filter/Roles.php
@@ -60,6 +60,8 @@ public static function create(ContainerInterface $container, array $configuratio
   public function getValueOptions() {
     $this->valueOptions = user_role_names(TRUE);
     unset($this->valueOptions[RoleInterface::AUTHENTICATED_ID]);
+    return $this->valueOptions;
+
   }
 
   /**
diff --git a/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php b/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php
index b781f074815b..5cdf6b90ac6f 100644
--- a/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php
@@ -74,7 +74,6 @@ public function testFilterPermission() {
 
     $view->initDisplay();
     $view->initHandlers();
-    $view->filter['permission']->getValueOptions();
 
     // Test the value options.
     $value_options = $view->filter['permission']->getValueOptions();
diff --git a/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php b/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php
index b105583d697f..6873a76551ad 100644
--- a/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\user\Entity\Role;
 use Drupal\views\Entity\View;
+use Drupal\views\Views;
 
 /**
  * Tests the roles filter handler.
@@ -52,6 +53,11 @@ public function testDependencies() {
     $expected['config'][] = 'user.role.test_user_role';
     $this->assertEqual($expected, $view->getDependencies());
 
+    $view = Views::getView('test_user_name');
+    $view->initDisplay();
+    $view->initHandlers();
+    $this->assertEqual(array_keys($view->filter['roles_target_id']->getValueOptions()), ['test_user_role']);
+
     $view = View::load('test_user_name');
     $display = &$view->getDisplay('default');
     $display['display_options']['filters']['roles_target_id'] = [
diff --git a/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php b/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php
index 00bc8c0c0321..2e1fc3e8d37b 100644
--- a/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php
@@ -83,6 +83,8 @@ public function testUserNameApi() {
 
     $this->executeView($view);
     $this->assertIdenticalResultset($view, array(array('uid' => $this->accounts[0]->id())), $this->columnMap);
+
+    $this->assertEqual($view->filter['uid']->getValueOptions(), NULL);
   }
 
   /**
diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php
index 3e3482a02629..042dca55ae62 100644
--- a/core/modules/views/src/Plugin/views/filter/InOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -59,8 +59,8 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
    * This can use a guard to be used to reduce database hits as much as
    * possible.
    *
-   * @return
-   *   Return the stored values in $this->valueOptions if someone expects it.
+   * @return array|NULL
+   *   The stored values from $this->valueOptions.
    */
   public function getValueOptions() {
     if (isset($this->valueOptions)) {
diff --git a/core/modules/views/src/Plugin/views/filter/LanguageFilter.php b/core/modules/views/src/Plugin/views/filter/LanguageFilter.php
index c42122c4ddea..f7eefb9a40cc 100644
--- a/core/modules/views/src/Plugin/views/filter/LanguageFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/LanguageFilter.php
@@ -69,6 +69,7 @@ public function getValueOptions() {
       // lost when there are changes in the language configuration.
       $this->valueOptions = $this->listLanguages(LanguageInterface::STATE_ALL | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED, array_keys($this->value));
     }
+    return $this->valueOptions;
   }
 
   /**
-- 
GitLab