Problem/Motivation

When previewing a view display that is using this module, specifically with arguments, there is a PHP warning displayed:

Warning: Invalid argument supplied for foreach() in Drupal\entityreference_filter\Plugin\views\filter\EntityReferenceFilterViewResult->getConfiguredViewsOptions() (line 228 of modules/contrib/entityreference_filter/src/Plugin/views/filter/EntityReferenceFilterViewResult.php).

Steps to reproduce

I'm using an exposed filter and passing a contextual argument of the form #n - argument number n of the contextual filter value

The view referenced by the exposed filter has a single contextual argument and "When the filter value is NOT available" is set to "Hide the view".

Since the contextual argument in my case is "required", previewing the view display without passing an argument results in this PHP warning.

Proposed resolution

Check $results in Drupal\entityreference_filter\Plugin\views\filter\EntityReferenceFilterViewResult->getConfiguredViewsOptions() so that we don't try to foreach() on null.

Remaining tasks

Patch
Others to be determined

User interface changes

n/a

API changes

n/a

Data model changes

n/a

CommentFileSizeAuthor
#3 entityreference_filter-3230004-3.patch1.37 KBstar-szr
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

Cottser created an issue. See original summary.

star-szr’s picture

Issue summary: View changes
Status: Active » Needs review
star-szr’s picture

Assigned: star-szr » Unassigned
StatusFileSize
new1.37 KB

Didn't mean to set needs review on the last comment, but here's a patch.

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

  • maximkashuba committed 1d8bc19 on 3230004-php-warning-when
    Issue #3230004. PHP warning when using arguments and previewing view...

  • maximkashuba committed 304fd88 on 3230004-pph-warning
    Issue #3230004. PHP warning when using arguments and previewing view...

  • maximkashuba committed d93e15f on 8.x-1.x
    Issue #3230004. PHP warning when using arguments and previewing view...

maximkashuba’s picture

@Cottser thank you for the patch.

maximkashuba’s picture

Status: Needs review » Fixed

Will be merged into master branch.

Status: Fixed » Closed (fixed)

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