Problem/Motivation

Upgrade to 1.26 breaks search (no results). Breaking change is the SearchApiQuery.php:519, the test $group_id === '' changed to $group_id == 0

Changing back to $group_id === '' fixes the issue

Steps to reproduce

Proposed resolution

Remaining tasks

Issue fork search_api-3313837

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

danb1974 created an issue. See original summary.

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

immaculatexavier’s picture

Status: Active » Needs review

Committed in accordance to the proposed resolution.

drunken monkey’s picture

Version: 8.x-1.26 » 8.x-1.x-dev
Component: General code » Views integration
Priority: Normal » Major
StatusFileSize
new756 bytes

@ danb1974: Thanks for reporting this problem! This would be a quite serious regression.
However, our automated tests seem to run fine, and in the code it seems to me like we always take care to set $group to 0 whenever it’s empty (including ''), so I’m not really sure how this might happen. Do you maybe have some code (other contrib module or custom) running on your site that adds/alters conditions by using \Drupal\search_api\Plugin\views\query\SearchApiQuery::getWhere() directly – or does some other more complex stuff with Views? Fixing that would be the smarter course of action.

However, I think I didn’t really realize, when making the change, that PHP would evaluate '' == 0 to FALSE, so it does look like a bug nonetheless. The attached should fix it, treating all empty values the same here.
Please test/review!

@ immaculatexavier: That’s not actually what danb1974 proposed, on the contrary, it seems like it would make the problem even worse. Also, please don’t use issue forks in this project, as the test bot doesn’t work for them (as you can see).

carolpettirossi’s picture

Status: Needs review » Needs work

I couldn't apply patch #5 on latest version 1.28

drunken monkey’s picture

Status: Needs work » Needs review

Still applies cleanly for me, both to 1.28 and dev. Could you please try again?
Otherwise, you can also make the change manually – it’s just a single line.

carolpettirossi’s picture

I'm so sorry. I was trying to apply this patch along with another one, and that's why it was failing. I could apply it successfully however it didn't solve my issue that is in fact related with something else and it is reported here: https://www.drupal.org/project/search_api/issues/3316665#comment-14788554

drunken monkey’s picture

Status: Needs review » Postponed (maintainer needs more info)

Did the patch committed in #3316665: Default group type OR is ignored in SearchApiQuery::build resolve this problem for everyone here? Then we can just close.