Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Facet results are wrapped in double quotes, and to properly display them without them double quotes are trimmed.
$result_filter = trim($result['filter'], '"');
This piece of code however trims all double quotes at the beginning and end of the result, even if they are part of the actual result. This can happen for example in the case of having a Width filter with string results in inches like 25".
The following patch more intelligently trims only one double quote at the beginning/end of the result.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2938735.patch | 2.68 KB | borisson_ |
Comments
Comment #2
krystalcode CreditAttribution: krystalcode at Acro Commerce commentedPatch attached.
Comment #4
borisson_Looks like this patch doesn't apply, what version was this made against? Can you try doing this against the latest dev-release?
Comment #5
borisson_Not sure why the changes in QueryString were needed, this should do the same. There is also a test now, that verifies that this works as it should.
Comment #6
StryKaizerComment #8
StryKaizerComment #10
TrevorBradley CreditAttribution: TrevorBradley commentedThis patch doesn't work for me, specifically because @krystalcode's changes to QueryString weren't kept as part of the patch.
The issue is that QueryString calls UrlProcessorPluginBase::setActiveItems, which still trims quotation marks BEFORE the code even gets over to SearchApiString. By the time the results get over to SearchApiString, they're already empty.
Since QueryString extends UrlProcessorPluginBase, it's possible to modify setActiveItems here to be kinder to dangling quotes.
It's likely the changes to SearchApiString are also requried. Investigating...
Comment #11
TrevorBradley CreditAttribution: TrevorBradley commentedOK, something is real screwy here.
Developing against 8.x-1.2: If I modify UrlPluginProcessorPluginBase::setActiveItems as per @krystalcode's suggestions:
This works perfectly, without any changes whatsoever to SearchApiString at all. My filters against strings that end in a quote work perfectly.
Obviously this is a closed isse, but I think it doesn't solve the core issue. Worse yet, it may be attempting to resolve the issue in the wrong file.
On my own site, I'm going to resolve this by extending the QueryString plugin to add in this modified setActiveItems, but I think there's still a fundamental issue here with facets dev. Not sure how to start resolving it - start a new issue so there's a new codebase to develop against?
Comment #12
TrevorBradley CreditAttribution: TrevorBradley commentedSince this is closed, I decided to adapt #3020427: Allow unpaired quotes on facet search fields into a new patch. This can stay closed.