Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
ed9b912d
Commit
ed9b912d
authored
9 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2561973
by geertvd, DuaelFr, Lendude: Unable to save view with permission filter handler
parent
6b464107
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/user/src/Tests/Views/FilterPermissionUiTest.php
+73
-0
73 additions, 0 deletions
core/modules/user/src/Tests/Views/FilterPermissionUiTest.php
core/modules/views/src/Plugin/views/filter/InOperator.php
+7
-5
7 additions, 5 deletions
core/modules/views/src/Plugin/views/filter/InOperator.php
with
80 additions
and
5 deletions
core/modules/user/src/Tests/Views/FilterPermissionUiTest.php
0 → 100644
+
73
−
0
View file @
ed9b912d
<?php
/**
* @file
* Contains \Drupal\user\Tests\Views\FilterPermissionUiTest.
*/
namespace
Drupal\user\Tests\Views
;
use
Drupal\views\Tests\ViewTestBase
;
use
Drupal\views\Tests\ViewTestData
;
/**
* Tests the permission field handler ui.
*
* @group user
* @see \Drupal\user\Plugin\views\filter\Permissions
*/
class
FilterPermissionUiTest
extends
ViewTestBase
{
/**
* Views used by this test.
*
* @var array
*/
public
static
$testViews
=
[
'test_filter_permission'
];
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
[
'user'
,
'user_test_views'
,
'views_ui'
];
protected
function
setUp
()
{
parent
::
setUp
(
TRUE
);
ViewTestData
::
createTestViews
(
get_class
(
$this
),
array
(
'user_test_views'
));
$this
->
enableViewsTestModule
();
}
/**
* Tests basic filter handler settings in the UI.
*/
public
function
testHandlerUI
()
{
$this
->
drupalLogin
(
$this
->
drupalCreateUser
([
'administer views'
,
'administer users'
]));
$this
->
drupalGet
(
'admin/structure/views/view/test_filter_permission/edit/default'
);
// Verify that the handler summary is correctly displaying the selected
// permission.
$this
->
assertLink
(
'User: Permission (= View user information)'
);
$this
->
drupalPostForm
(
NULL
,
[],
'Save'
);
// Verify that we can save the view.
$this
->
assertNoText
(
'No valid values found on filter: User: Permission.'
);
$this
->
assertText
(
'The view test_filter_permission has been saved.'
);
// Verify that the handler summary is also correct when multiple values are
// selected in the filter.
$edit
=
[
'options[value][]'
=>
[
'access user profiles'
,
'administer views'
,
],
];
$this
->
drupalPostForm
(
'admin/structure/views/nojs/handler/test_filter_permission/default/filter/permission'
,
$edit
,
'Apply'
);
$this
->
assertLink
(
'User: Permission (or View us…)'
);
$this
->
drupalPostForm
(
NULL
,
[],
'Save'
);
// Verify that we can save the view.
$this
->
assertNoText
(
'No valid values found on filter: User: Permission.'
);
$this
->
assertText
(
'The view test_filter_permission has been saved.'
);
}
}
This diff is collapsed.
Click to expand it.
core/modules/views/src/Plugin/views/filter/InOperator.php
+
7
−
5
View file @
ed9b912d
...
...
@@ -330,6 +330,8 @@ public function adminSummary() {
$info
=
$this
->
operators
();
$this
->
getValueOptions
();
// Some filter_in_operator usage uses optgroups forms, so flatten it.
$flat_options
=
OptGroup
::
flattenOptions
(
$this
->
valueOptions
);
if
(
!
is_array
(
$this
->
value
))
{
return
;
...
...
@@ -340,7 +342,7 @@ public function adminSummary() {
if
(
in_array
(
$this
->
operator
,
$this
->
operatorValues
(
1
)))
{
// Remove every element which is not known.
foreach
(
$this
->
value
as
$value
)
{
if
(
!
isset
(
$
this
->
valueO
ptions
[
$value
]))
{
if
(
!
isset
(
$
flat_o
ptions
[
$value
]))
{
unset
(
$this
->
value
[
$value
]);
}
}
...
...
@@ -356,8 +358,8 @@ public function adminSummary() {
$keys
=
$this
->
value
;
$value
=
array_shift
(
$keys
);
if
(
isset
(
$
this
->
valueO
ptions
[
$value
]))
{
$values
=
SafeMarkup
::
checkPlain
(
$
this
->
valueO
ptions
[
$value
]);
if
(
isset
(
$
flat_o
ptions
[
$value
]))
{
$values
=
SafeMarkup
::
checkPlain
(
$
flat_o
ptions
[
$value
]);
}
else
{
$values
=
''
;
...
...
@@ -372,8 +374,8 @@ public function adminSummary() {
$values
=
Unicode
::
truncate
(
$values
,
8
,
FALSE
,
TRUE
);
break
;
}
if
(
isset
(
$
this
->
valueO
ptions
[
$value
]))
{
$values
.
=
SafeMarkup
::
checkPlain
(
$
this
->
valueO
ptions
[
$value
]);
if
(
isset
(
$
flat_o
ptions
[
$value
]))
{
$values
.
=
SafeMarkup
::
checkPlain
(
$
flat_o
ptions
[
$value
]);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment