Views filter getBundles is fragile

Created on 3 April 2019, over 5 years ago
Updated 29 November 2023, 12 months ago

Problem/Motivation

\Drupal\state_machine\Plugin\views\filter\State::getBundles takes two approaches to getting the bundles to retrieve workflows for. Both of these have some fragility:

  1. Bundle key is a filter: this is prone to conflicts, probably with high probability. type is a common bundle key, if you have a view with entity A and entity B, both with bundle key type, with a bundle filter on A and a state filter on B, you will get an invalid list of bundles.
  2. Fall back to EntityFieldManagerInterface::getFieldMap for field bundles: This is fragile due to a core bug (or arguable a poorly defined API which contrib makes use of) #3045509: EntityFieldManager::getFieldMap() doesn't show bundle fields resulting in the field map not being accurate.

Proposed resolution

  1. Could be solved by doing some checking against the filter handlers to be more accurate, essentially looping over them.
  2. It is safer here to use EntityTypeBundleInfoInterface::getBundleInfo. It does result in creating more workflows than is perhaps necessary, but if performance is an issue, we could always cache the results of Status::getValueOptions, with appropriate tags that should be fairly reliable with changes elsewhere.

User interface changes

Should be none.

API changes

A change to the injected services - not sure if that is going to be an issue for BC. I know my short term solution to this has been to extend, but then I would be expecting to drop that when this is fixed. Not sure what other use case there would be for extending this.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom andrewbelcher

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Pipeline finished with Skipped
    over 1 year ago
    #13874
  • Pipeline finished with Skipped
    over 1 year ago
    #13961
  • 🇺🇦Ukraine khiminrm

    I've also faced with the same issue. I had views based on commerce_invoice entity type and with relation to orders. I had filter for invoice type (bundle) and tried to add exposed filter by the order state. The code of the State filter tried to get bundle of the commerce_invoice filter and to get states for not existing commerce_order bundle - from the value of the commerce_invoice bundle filter.

    I've created patch which works for my case and hope will work for others.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    27 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    27 pass
  • Pipeline finished with Skipped
    over 1 year ago
    #16004
  • Pipeline finished with Skipped
    over 1 year ago
    #16282
  • Pipeline finished with Skipped
    over 1 year ago
    #16352
  • Pipeline finished with Skipped
    over 1 year ago
    #16354
  • Pipeline finished with Skipped
    about 1 year ago
    #39099
  • Pipeline finished with Success
    about 1 year ago
    Total: 147s
    #48260
  • Status changed to Fixed 12 months ago
  • 🇮🇱Israel jsacksick

    Committed, thanks!

  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 12 months ago
    Waiting for branch to pass
  • Status changed to Needs review 12 months ago
  • 🇺🇸United States TomTech

    Added additional handling in the case where multiple type filters may be present, so we can't rely on the filter key.

    This also handles multiple type filters and does not treat a filter with the not in operator the same as the in operator.

  • Pipeline finished with Skipped
    12 months ago
    #56618
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 12 months ago
    27 pass
  • Status changed to Fixed 12 months ago
  • 🇮🇱Israel jsacksick

    Trusting you on this, committed!

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Canceled
    11 months ago
    Total: 113s
    #64588
  • Pipeline finished with Failed
    11 months ago
    #71874
  • Pipeline finished with Success
    11 months ago
    #71883
  • Pipeline finished with Success
    11 months ago
    #72352
  • Pipeline finished with Failed
    11 months ago
    Total: 179s
    #75983
  • Pipeline finished with Failed
    11 months ago
    #76004
  • Pipeline finished with Failed
    10 months ago
    Total: 771s
    #79314
  • Pipeline finished with Failed
    10 months ago
    Total: 889s
    #79321
  • Pipeline finished with Success
    10 months ago
    #81729
  • Pipeline finished with Success
    10 months ago
    Total: 172s
    #83071
  • Pipeline finished with Success
    10 months ago
    Total: 139s
    #90547
  • Pipeline finished with Success
    10 months ago
    Total: 286s
    #92114
  • Pipeline finished with Success
    9 months ago
    Total: 171s
    #94293
  • Pipeline finished with Skipped
    9 months ago
    #105604
  • Pipeline finished with Failed
    9 months ago
    #105914
  • Pipeline finished with Success
    9 months ago
    #106506
  • Pipeline finished with Success
    9 months ago
    Total: 165s
    #116026
  • Pipeline finished with Success
    9 months ago
    #116248
  • Pipeline finished with Success
    9 months ago
    Total: 215s
    #116487
  • Pipeline finished with Success
    8 months ago
    Total: 330s
    #118079
  • Pipeline finished with Failed
    8 months ago
    Total: 603s
    #119813
  • Pipeline finished with Success
    8 months ago
    Total: 649s
    #119886
  • Pipeline finished with Failed
    8 months ago
    Total: 3825s
    #121410
  • Pipeline finished with Success
    8 months ago
    Total: 293s
    #121519
  • Pipeline finished with Success
    8 months ago
    Total: 173s
    #121528
  • Pipeline finished with Failed
    8 months ago
    #123759
  • Pipeline finished with Canceled
    8 months ago
    Total: 115s
    #132852
  • Pipeline finished with Success
    8 months ago
    Total: 158s
    #132872
  • Pipeline finished with Failed
    8 months ago
    Total: 153s
    #132883
  • Pipeline finished with Failed
    8 months ago
    Total: 156s
    #132887
  • Pipeline finished with Success
    8 months ago
    Total: 139s
    #135196
  • Pipeline finished with Success
    8 months ago
    Total: 165s
    #135268
  • Pipeline finished with Success
    7 months ago
    Total: 137s
    #146903
  • Pipeline finished with Success
    7 months ago
    Total: 194s
    #146927
  • Pipeline finished with Success
    7 months ago
    Total: 150s
    #148682
  • Pipeline finished with Success
    7 months ago
    Total: 150s
    #148683
  • Pipeline finished with Success
    7 months ago
    Total: 149s
    #148687
  • Pipeline finished with Skipped
    7 months ago
    #155366
  • Pipeline finished with Success
    7 months ago
    Total: 102s
    #158908
  • Pipeline finished with Success
    7 months ago
    Total: 399s
    #159407
  • Pipeline finished with Success
    7 months ago
    #160405
  • Pipeline finished with Manual
    7 months ago
    #160591
  • Pipeline finished with Success
    7 months ago
    Total: 172s
    #160753
  • Pipeline finished with Success
    7 months ago
    Total: 132s
    #162216
  • Pipeline finished with Failed
    7 months ago
    Total: 277s
    #162230
  • Pipeline finished with Canceled
    7 months ago
    Total: 37s
    #166083
  • Pipeline finished with Skipped
    7 months ago
    #166562
  • Pipeline finished with Failed
    7 months ago
    #166781
  • Pipeline finished with Success
    7 months ago
    Total: 164s
    #167222
  • Pipeline finished with Success
    7 months ago
    Total: 244s
    #168927
  • Pipeline finished with Success
    6 months ago
    Total: 163s
    #172124
  • Pipeline finished with Success
    6 months ago
    Total: 170s
    #172298
  • Pipeline finished with Pending
    6 months ago
    #172799
  • Pipeline finished with Success
    6 months ago
    Total: 139s
    #173584
  • Pipeline finished with Success
    6 months ago
    Total: 177s
    #173731
  • Pipeline finished with Success
    6 months ago
    Total: 140s
    #173779
  • Pipeline finished with Success
    6 months ago
    Total: 358s
    #173834
  • Pipeline finished with Success
    6 months ago
    Total: 170s
    #174126
  • Pipeline finished with Success
    6 months ago
    Total: 172s
    #174328
  • Pipeline finished with Failed
    6 months ago
    #181240
  • Pipeline finished with Failed
    6 months ago
    Total: 161s
    #181402
  • Pipeline finished with Success
    6 months ago
    Total: 304s
    #181536
  • Pipeline finished with Failed
    6 months ago
    Total: 260s
    #182430
  • Pipeline finished with Skipped
    6 months ago
    #182447
  • Pipeline finished with Failed
    6 months ago
    #189112
  • Pipeline finished with Failed
    6 months ago
    Total: 224s
    #189160
  • Pipeline finished with Failed
    6 months ago
    Total: 273s
    #189192
  • Pipeline finished with Failed
    6 months ago
    Total: 141s
    #194835
  • Pipeline finished with Failed
    6 months ago
    Total: 139s
    #194847
  • Pipeline finished with Success
    5 months ago
    Total: 143s
    #196321
  • Pipeline finished with Success
    5 months ago
    Total: 152s
    #199500
  • Pipeline finished with Success
    5 months ago
    Total: 279s
    #199513
  • Pipeline finished with Success
    5 months ago
    Total: 144s
    #199528
  • Pipeline finished with Success
    5 months ago
    Total: 145s
    #199530
  • Pipeline finished with Success
    5 months ago
    Total: 218s
    #202797
  • Pipeline finished with Canceled
    5 months ago
    Total: 113s
    #202808
  • Pipeline finished with Success
    5 months ago
    Total: 236s
    #202812
  • Pipeline finished with Skipped
    5 months ago
    #203961
  • Pipeline finished with Success
    5 months ago
    Total: 281s
    #207210
  • Pipeline finished with Skipped
    5 months ago
    #207249
  • Pipeline finished with Failed
    5 months ago
    Total: 284s
    #207266
  • Pipeline finished with Success
    5 months ago
    #207347
  • Pipeline finished with Success
    5 months ago
    Total: 193s
    #210176
  • Pipeline finished with Success
    5 months ago
    #214009
  • Pipeline finished with Failed
    5 months ago
    #218948
  • Pipeline finished with Failed
    5 months ago
    Total: 170s
    #219153
  • Pipeline finished with Failed
    5 months ago
    Total: 194s
    #219571
  • Pipeline finished with Canceled
    4 months ago
    Total: 154s
    #228465
  • Pipeline finished with Success
    4 months ago
    Total: 172s
    #228466
  • Pipeline finished with Success
    4 months ago
    Total: 170s
    #228469
  • Pipeline finished with Success
    4 months ago
    Total: 79s
    #230329
Production build 0.71.5 2024