diff --git a/core/modules/comment/src/Plugin/views/filter/NodeComment.php b/core/modules/comment/src/Plugin/views/filter/NodeComment.php index a83ec39..2340752 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 5d73454..7d6db6f 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 591ad17..b3cc5d8 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 690ec6d..83c789f 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 a4be2f5..0066f71 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 c113b2e..6cbb703 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 bcae6f9..e017c64 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 b781f07..5cdf6b9 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 b105583..6873a76 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 00bc8c0..2e1fc3e 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 3e3482a..042dca5 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 c42122c..f7eefb9 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; } /**