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

  1. Create Drupal View using version 8.x-1.0-alpha3
  2. Upgrade code to version 2.0.0-alpha1
  3. 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:

  1. Create a hook_update_n() that adds the setting to any View that doesn't have it.
  2. Update the code in EREFNodeTitles::generateOptions() to not throw warnings when the setting option isn't there.
  3. 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.

Command icon 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

jrb created an issue. See original summary.

jrb’s picture

Issue summary: View changes
abhishek_gupta1’s picture

Assigned: Unassigned » abhishek_gupta1
abhishek_gupta1’s picture

Assigned: abhishek_gupta1 » Unassigned
Status: Active » Needs review
StatusFileSize
new1.27 KB

@el1_1el, i have fixed the issue, Please Kindly review the Patch file.

samir_shukla’s picture

StatusFileSize
new20.04 KB

Hi, i tried to apply the patch, it got failed. Here is the screenshot of the error i got.

stefank’s picture

Ignore this patch. Sorry about that.

stefank’s picture

StatusFileSize
new1.24 KB

Sorry, here is another patch, which doesnt have double accessCheck.

gustavowal’s picture

+1
Thanks @abhishek_gupta1 and @stefank for updated patch, applying that corrects all those warnings.

stefank’s picture

StatusFileSize
new1.29 KB

Right, here is another go, as the previous patches still left some warnings in some conditions. this one should prevent it.

niral098’s picture

#7 works and fixes the warnings mentioned above. Thank you.

itsprashantbais’s picture

StatusFileSize
new49.88 KB

Hi @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

itsprashantbais’s picture

Status: Needs review » Needs work

makbay made their first commit to this issue’s fork.

makbay’s picture

Version: 2.0.0-alpha1 » 2.0.x-dev

makbay changed the visibility of the branch 3377861-php-undefined-array to hidden.

makbay’s picture

Status: Needs work » Needs review
StatusFileSize
new1.23 KB

The MR should resolve the issue. Here is a patch.

  • el1_1el committed 2a836b9f on 2.0.x authored by makbay
    Issue #3377861 by makbay, stefank, abhishek_gupta1, __i.am.prashant__,...
el1_1el’s picture

Status: Needs review » Fixed

Fixed and released as 2.0.0-alpha2. Thanks everyone!

makbay’s picture

Thank you and could you please give the credits for people that have tried to fix this?

el1_1el’s picture

sorry. thought the commit message would do but it did not. 2 step process, lesson learned. Thanks for pointing it out!

makbay’s picture

No worries and thank you =)

Status: Fixed » Closed (fixed)

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