Problem/Motivation
After upgrading from 8.x-1.0-alpha3 to 2.0.0-alpha1, we starting getting these PHP warnings:
Warning: Undefined array key "sort_bundle_order" in Drupal\entity_reference_exposed_filters\Plugin\views\filter\EREFNodeTitles->generateOptions() (line 379 of /app/web/modules/contrib/entity_reference_exposed_filters/src/Plugin/views/filter/EREFNodeTitles.php)
Warning: Undefined array key "" in Drupal\entity_reference_exposed_filters\Plugin\views\filter\EREFNodeTitles->generateOptions() (line 379 of /app/web/modules/contrib/entity_reference_exposed_filters/src/Plugin/views/filter/EREFNodeTitles.php)
Deprecated function: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Entity\Query\QueryBase->sort() (line 240 of /app/web/core/lib/Drupal/Core/Entity/Query/QueryBase.php)
The issue is that a new "Sort bundles" setting was added to the Entity Reference Exposed Filters Node Titles filter. Views created with an older version of this module don't have this setting, and there is no default.
Steps to reproduce
- Create Drupal View using version 8.x-1.0-alpha3
- Upgrade code to version 2.0.0-alpha1
- View page that uses the Drupal View
Proposed resolution
The simplest way for a user to fix this is to edit the View, click on the"Settings" link for the filter, set the "Sort bundles" value, apply the changes, and save the view.
The actual solution would be to do one of the following:
- Create a
hook_update_n()that adds the setting to any View that doesn't have it. - Update the code in
EREFNodeTitles::generateOptions()to not throw warnings when the setting option isn't there. - Add a note to the release notes for the 2.0 versions that tells people to go re-save the View per above.
Remaining tasks
Do one of the options above.
Mostly, I just wanted to document this for others that encountered the same issue since it's an easy fix.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | entity_reference_exposed_filters_3377861.patch | 1.23 KB | makbay |
| #11 | Screenshot from 2024-02-15 18-15-44.png | 49.88 KB | itsprashantbais |
| #9 | entity_reference_exposed_filters_3377861-9.patch | 1.29 KB | stefank |
| #5 | exposed-filter.png | 20.04 KB | samir_shukla |
| #4 | entity_reference_exposed_filters_3377861.patch | 1.27 KB | abhishek_gupta1 |
Issue fork entity_reference_exposed_filters-3377861
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jrbComment #3
abhishek_gupta1 commentedComment #4
abhishek_gupta1 commented@el1_1el, i have fixed the issue, Please Kindly review the Patch file.
Comment #5
samir_shuklaHi, i tried to apply the patch, it got failed. Here is the screenshot of the error i got.
Comment #6
stefank commentedIgnore this patch. Sorry about that.
Comment #7
stefank commentedSorry, here is another patch, which doesnt have double accessCheck.
Comment #8
gustavowal commented+1
Thanks @abhishek_gupta1 and @stefank for updated patch, applying that corrects all those warnings.
Comment #9
stefank commentedRight, here is another go, as the previous patches still left some warnings in some conditions. this one should prevent it.
Comment #10
niral098#7 works and fixes the warnings mentioned above. Thank you.
Comment #11
itsprashantbais commentedHi @stefank,
none of the patch worked well even after when I apply patch and then go for add
Entity Reference Exposed Filter is still throw warning messages. Please see attached screenshot. thanks
Comment #12
itsprashantbais commentedComment #14
makbay commentedComment #17
makbay commentedThe MR should resolve the issue. Here is a patch.
Comment #19
el1_1el commentedFixed and released as 2.0.0-alpha2. Thanks everyone!
Comment #20
makbay commentedThank you and could you please give the credits for people that have tried to fix this?
Comment #21
el1_1el commentedsorry. thought the commit message would do but it did not. 2 step process, lesson learned. Thanks for pointing it out!
Comment #22
makbay commentedNo worries and thank you =)