diff --git a/core/modules/comment/src/Plugin/views/filter/NodeComment.php b/core/modules/comment/src/Plugin/views/filter/NodeComment.php index a83ec3930fd61440929629182aa09b53626a6058..234075289090f522469b86b6e2f95123af06ca82 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 5d73454dd66f12a6003c5c69bffb03646df9a88b..7d6db6f26dc0db3ae2097cd864436279f09c87d5 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 591ad179c2a95d4b87816443cbda63b1ff4ee578..b3cc5d81988bbd7136feb30129fe9329d0f40c73 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 46b8eb9ac6d7c1cdcf008cd7903cba308f1cae63..c660d20ff856564c879a97d3507c261adc18c1dd 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 a4be2f547f97ad20c79ef6f58da1ae14ded2f841..0066f712786f1fee930d28d83ff316276fac755c 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 c113b2eee39e7c8db43e886a58e78176c5286f5b..6cbb703970cd36e179f802a2d5169c11e7101f69 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 bcae6f94cdc2493f9eb9f5876f17d73139a888b5..e017c647ab29e82905bd31351fde2646ec9bafdd 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 b781f074815b0e9628a6edac791f6f7c4dc37aa3..5cdf6b90ac6f3c1bf198b8a5c6bb40473116bf6c 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 b105583d697fcc055ac50aaa31ba24e812ad79bf..6873a76551ad06334dd60b1ee4352ae264aa12b4 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 00bc8c0c0321e9cbc89c9aacb6c031977b055d32..2e1fc3e8d37b9e7dc27e54b154a1484f5d4044c2 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 89a731c967fa4a70874eb508f5d7ab287459dc73..cfcde0e52368ae8d63a2fc68d22875bb986ac677 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 c42122c4ddea903ec8f9bdb528023c368188846a..f7eefb9a40cc30f0caa0afc5551983d7695d6dc2 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; } /**