Problem/Motivation

similarterms/src/Plugin/views/argument/SimilarTermsArgument.php::validateArgument() returns FALSE, which causes no results in the view filtered by the contextual filter "Similar by terms: Nid".

Steps to reproduce

Create a view and add a contextual fitler "Similar by terms: Nid". Do not select any vocabularies in the field "Limit similarity to terms within these vocabularies".

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

max-kuzomko created an issue. See original summary.

max-kuzomko’s picture

Assigned: max-kuzomko » Unassigned
Status: Active » Needs review
StatusFileSize
new637 bytes

The issue happens because the condition if ($val === 0) doesn't work when the $val is actually a string '0'. Added a fix.

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

vitaliyb98’s picture

In the MR, I provided a fix that resolves this issue and avoids the need for additional foreach loops:

    foreach ($vocabulary_vids as $key => $val) {
      if ($val === 0) {
        unset($vocabulary_vids[$key]);
      }
    }

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

shelane’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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