I have a directory of people that uses a contextual filter on a name filed that uses the family component to build an alphabetic glossary. So the filter has a fixed value of a+b+c+d and allows multiple values.

All worked well for years until I upgraded to 7.x-3.22. Now the display of contact names is empty, and if I go to edit the display I get the following error:

SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

If I change the filter to display all values when no argument is provided, the list of names reappears. But I no longer have my glossary.

I can roll back to 7.x-3.22 for now. But it would be great to know what's causing the problem.

Comments

rsbecker created an issue. See original summary.

rsbecker’s picture

Issue summary: View changes
damienmckenna’s picture

Status: Active » Postponed (maintainer needs more info)

Please test the latest 7.x-3.23 release, it included a number of fixes to how queries were built and should resolve the problem. Thanks.

rsbecker’s picture

The problem started when I upgraded to 7.x-3.23. The drop down list didn’ go above 7.x-3.22.

I have rolled back to 7.x-3.22 to make my displays work again.

rsbecker’s picture

Title: Upgrade to 7.x-3.22 breaks glossary mode » Upgrade to 7.x-3.23 breaks glossary mode
damienmckenna’s picture

Status: Postponed (maintainer needs more info) » Active

Ok, thanks for the clarification.

I'll check with the d.o folks on why the 7.x-3.23 release doesn't show in the version selector.

damienmckenna’s picture

Might it be possible for you to provide an export of the View configuration that shows the problem? Would you mind cloning the existing view and trimming it down to just the bare fields that show the problem?

rsbecker’s picture

StatusFileSize
new88.49 KB
new153.26 KB

I've attached an export of the view and a screenshot of the page when the view is working. This is a complex view that works with CRM-Core contacts and AbleOrganizer, so it would be difficult to strip out anything. The two displays that we actually use are Individuals and Families.

mustanggb’s picture

Version: 7.x-3.22 » 7.x-3.23
jberg1’s picture

Same issue here.
My glossary broke, not allowing multiple arguments.

/glossary-view/a
Worked fine. But
/glossary-view/a,b,c
Only returned "no results behavior".
and preview in views returned this error.
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

Rolling back to 3.22 solved my issue.
Hoping for resolution in next version.

Thanks.

feyp’s picture

This regression has been introduced in commit 69c99e6d. The relevant issue was #1930472: Add exclude support to string contextual filter handler. Reverting that commit fixes it. I haven't looked into how to best fix this, yet.

feyp’s picture

Status: Active » Needs review
StatusFileSize
new712 bytes

Patch against 7.x-3.x attached. I'll see, if I have the time to add a test.

feyp’s picture

StatusFileSize
new4.23 KB
new4.93 KB

Added some tests to the existing test for this handler that should cover this regression.

The last submitted patch, 13: n3055856-13-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

brankoc’s picture

Version: 7.x-3.23 » 7.x-3.x-dev
brankoc’s picture

You can reproduce this bug using just the default Glossary view after making a small modification to that view. The modification will allow you to enter multiple arguments separated by + or ,.

In the Edit screen of the view Glossary, under Advanced / Contextual filters, click on Content:title.

In the Content: Title pop-up, under More check Allow multiple values.

Click Apply (all displays).

---

Trying the default Glossary view modified as outlined above produces the results the original reporter and #10 reported.

---

Applying the patch from #13 allows me to view multiple glossary items again.

It also makes the error message on the view edit screen go away.

---

I haven't fully tested the patch, because I don't know well enough what glossary mode is supposed to do.

Two things I noticed that may not be a problem:

- The test is part of the string argument handler tests. Why not the glossary tests?

- According to the setting described above, "if selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND)." I get the same results regardless of whether I use comma (,) or plus (+). In both cases the system uses OR, i.e. displays matches for each argument in the list. To be honest, I have no idea what AND is even supposed to do.

damienmckenna’s picture

Anyone have time to rewrite the tests per #16? Thanks.

damienmckenna’s picture

brankoc’s picture

Status: Needs review » Needs work
Related issues: +#1534720: Contextual filter (string) won't accept multiple values

The problem with AND and OR operators in the argument seems to be a much older one, so I think we can assume that wasn't introduced with 7.x-3.23 and is therefore not part of this bug: Contextual filter (string) won't accept multiple values.

Considering that tests remain to be written, I have set the status to Needs Work.

feyp’s picture

Status: Needs work » Needs review
StatusFileSize
new10.2 KB
new10.89 KB

Sorry for taking that long to respond. I've been busy with other stuff...

The test is part of the string argument handler tests. Why not the glossary tests?

I think you are suggesting that we should remove the string argument handler test entirely and merge everything into the glossary test, right? If this is not what you wanted to be done, it would be nice if you could elaborate a little bit on what exactly you think should be done. No interdiff, since it's trivial.

brankoc’s picture

My apologies for the confusion.

There is no "what I think needs to be done". I have only little experience with testing (in Drupal or in general), and practically none with testing in Views. It simply struck me as odd that tests pertaining to glossaries were in the string argument handler tests, but I admit this may very well be fine.

As a result we get into this game of Chinese whispers where I say: "I don't know anything about the subject matter, but this feels strange", the maintainer concludes "the tests must be rewritten", and you end up rewriting tests on the basis of what you think my hunches mean.

Unless I only write about what I know, I don't see how to avoid this, but maybe you could ask what I mean before rewriting tests.

I think you are suggesting that we should remove the string argument handler test entirely and merge everything into the glossary test, right?

I don't know who added the string argument handler tests and why; nor if these tests are referenced elsewhere.

So no, that is not what I was suggesting.

I hadn't really looked deeply in how all the Views tests interact and how they are structured. All I saw was that the assertions you had added in #13 were part of a class ViewsHandlerArgumentStringTest in a file views_handler_argument_string.test, which struck me as odd, because the reporter was having problems with their glossary and the assertions seemed to deal with glossaries.

Let me see if I can come up with a patch that does what I was thinking of at the time.

feyp’s picture

Don't worry, it's fine with me :). I had made changes to the string handler, so when looking where to best add tests, I immediately found the string handler test and the only thing it was testing was the glossary mode, so I thought it was ok to just extend that. Only after reading your comment I became aware of the glossary test and since everything that was tested in the original string handler test was already tested by the glossary test (actually the original string handler test didn't do very much), I thought that your comment, supposedly about merging everything into one test, was reasonable, but I wasn't entirely sure.

Anyway, feel free to provide a new patch and I'll see if I have time to review it. I guess next time I'll maybe try to track you down in Slack or just ask in the issue, if I'm not entirely sure.

brankoc’s picture

I immediately found the string handler test and the only thing it was testing was the glossary mod

This is the piece of the puzzle that only became clear to me now.

Given that the string handler test only tests glossaries and given that having two different places for testing glossaries has already proven to be confusing, I prefer patch #20 over patch #13.

I can confirm that patch #20 allows me to view multiple glossary items.

brankoc’s picture

I am not going to come up with my own patch as I think #20 works just fine.

This is a full review of patch #20:

- No (new) standards issues found.

- Line 192: I would write 'char' out full as 'character' unless 'char' has a specific meaning here that is different from 'character'.

- Line 225: why no $view->destroy(); here?

- Maybe each cluster of assertions should have a comment explaining what is being tested.

E.g.

// Checks that a glossary view with an argument containing one letter
// returns only the nodes that start with that letter.

// Checks that a glossary view with an argument containing multiple
// values returns only and all nodes that start with these values.

// Checks that a glossary view with a phrase as an argument does
// not interpret that phrase as multiple values.

// Checks that a glossary view with an argument containing one letter
// excludes all nodes that start with that letter.

// Checks that a glossary view with an argument containing multiple
// values excludes all nodes that start with these values.

I do not think this is mandatory as per the coding guidelines, but to me it is not immediately clear from reading the assertions only what each test does; for this I need to read the code. That is why I think comments could be valuable.

In the examples above I have employed terminology as used by Views UI, i.e. 'multiple arguments' instead of 'break phrase', 'exclude' instead of 'not', and so on. This may help others find the tests for each setting.

feyp’s picture

StatusFileSize
new7.22 KB
new11.41 KB
new12.11 KB

Thank's for the review!

Line 192: I would write 'char' out full as 'character' unless 'char' has a specific meaning here that is different from 'character'.

Done.

Line 225: why no $view->destroy(); here?

Good catch!

Maybe each cluster of assertions should have a comment explaining what is being tested.

I agree that it is a good idea, also using the wording from the UI to make it more discoverable. I've added the comments you suggested and an extra one for the sorting.

And another change I made on top: When I was retesting the changes locally I discovered that MySQL sorts a little bit different than my PHP implementation, so #20 could have caused random test fails. MySQL places upper case letters first, PHP places lower case letters first. To avoid that I just transform the titles to lowercase now.

feyp’s picture

StatusFileSize
new7.22 KB

Whoops, don't know why I used test as extension for the interdiff instead of txt. Sorry!

brankoc’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that after applying patch #25, I can filter on multiple values in a glossary view.

  • DamienMcKenna committed a85066c on 7.x-3.x authored by FeyP
    Issue #3055856 by FeyP, rsbecker, BrankoC, DamienMcKenna, jberg1:...
damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you.

Status: Fixed » Closed (fixed)

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