Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
state_machine
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
state_machine
Commits
7bb0ef9f
Commit
7bb0ef9f
authored
1 year ago
by
Tom Ashe
Committed by
Jonathan Sacksick
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3045520
by khiminrm, jsacksick: Views filter getBundles is fragile
parent
ffb257d2
No related branches found
No related tags found
2 merge requests
!26
Draft: Automated Project Update Bot fixes
,
!18
Issue #3045520 by khiminrm, jsacksick: Views filter getBundles is fragile
Pipeline
#56619
passed
1 year ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/views/filter/State.php
+27
-5
27 additions, 5 deletions
src/Plugin/views/filter/State.php
with
27 additions
and
5 deletions
src/Plugin/views/filter/State.php
+
27
−
5
View file @
7bb0ef9f
...
...
@@ -167,11 +167,33 @@ class State extends InOperator {
protected
function
getBundles
(
EntityTypeInterface
$entity_type
,
$field_name
)
{
$bundles
=
[];
$bundle_key
=
$entity_type
->
getKey
(
'bundle'
);
if
(
$bundle_key
&&
isset
(
$this
->
view
->
filter
[
$bundle_key
]))
{
$filter
=
$this
->
view
->
filter
[
$bundle_key
];
if
(
!
$filter
->
isExposed
()
&&
!
empty
(
$filter
->
value
)
&&
$filter
->
getEntityType
()
===
$entity_type
->
id
())
{
// 'all' is added by Views and isn't a bundle.
$bundles
=
array_diff
(
$filter
->
value
,
[
'all'
]);
if
(
$bundle_key
)
{
// Get any bundle filters for this entity type and bundle.
// It is unlikely, but there could be multiple.
/** @var \Drupal\views\Plugin\views\filter\FilterPluginBase[] $bundle_filters */
$bundle_filters
=
array_filter
(
$this
->
view
->
filter
??
[],
static
function
(
$filter
)
use
(
$entity_type
,
$bundle_key
)
{
return
$filter
->
getEntityType
()
===
$entity_type
->
id
()
&&
$filter
->
realField
===
$bundle_key
;
});
foreach
(
$bundle_filters
as
$bundle_filter
)
{
if
(
$bundle_filter
->
isExposed
())
{
// If any bundle filters are exposed,
// we cannot return a subset of bundles.
$bundles
=
[];
break
;
}
switch
(
$bundle_filter
->
operator
)
{
case
'in'
:
$bundles
=
array_merge
(
$bundles
,
$bundle_filter
->
value
);
break
;
case
'not in'
:
$bundles
=
array_diff
(
$bundles
,
$bundle_filter
->
value
);
break
;
}
}
// Remove the "all" option, if present.
if
(
array_key_exists
(
'all'
,
$bundles
))
{
unset
(
$bundles
[
'all'
]);
}
}
// Fallback to the list of bundles the field is attached to.
...
...
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