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.
Commit of #2772829 broke Solr Integration tests and lets facets disappear
Comment | File | Size | Author |
---|---|---|---|
#95 | use_search_api_s-2794745-95.patch | 7.1 KB | borisson_ |
Comments
Comment #2
mkalkbrennerComment #3
mkalkbrennerComment #4
mkalkbrennerFirst, the search_id is now a query property. Here's a small patch. After applying it the search_id in the Solr integration test is "views_page:search_api_test_view__page_1".
But getFacetsByFacetSourceId('views_page:search_api_test_view__page_1') doesn't return any facets.
Comment #5
mkalkbrennerComment #7
mpp CreditAttribution: mpp commentedBefore #2772829 facets_search_api_query_alter is invoked just once:
After #2772829 facets_search_api_query_alter is invoked twice:
and
At first sight it appeared that search_api_display is missing:
But this is removed in #2772829:
Before #2772829, results came from the static cache in fillFacetsWithResults():
After #2772829 the static cache appears empty and the following part in fillFacetsWithResults() returns no results:
The problem is here:
The search ID should be set, if it was not already set.
Comment #8
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #9
mpp CreditAttribution: mpp as a volunteer and at AmeXio commented@mkalkbrenner, I guess you'll need to commit that on search_api and then re-assign this to @boris to commit your patch on facets and fix tests there.
Comment #10
borisson_I committed @mkalkbrenner's patch
Comment #11
edutrul CreditAttribution: edutrul as a volunteer and at Anexus commentedLast patch #8 from mpp works as expected! I've tested out and facets do display as expected!
@borisson_
looks like I do not see your commit in search_api history, could you please double check it and commit!
Thanks for all your effort!
Comment #12
edutrul CreditAttribution: edutrul as a volunteer and at Anexus commentedfyi: Actually @borisson_ I see your commit:
but that doesn't fix facets disappear!
instead PATCH from #8 does make it work for me
Thanks
Comment #13
borisson_I have no commit rights on search_api, I only committed the facets patch.
Comment #14
mpp CreditAttribution: mpp as a volunteer and at AmeXio commented@edutrul, both patches are required:
The one in facets is needed as search API added in #2772829 a different method to get the search id "getSearchId".
The one in search_api is needed as the search id should always be set.
Comment #15
mkalkbrennerIn the init() method of the same class the search ID is built a little bit different:
I wonder why they're not identical. But I'm not familiar with that detail yet.
Comment #16
mkalkbrennerComment #17
Hydra CreditAttribution: Hydra at erdfisch commented#8 Makes it work for me. It think this should be committed first and the inconsistent search_id generation cleanup then be addressed in a separate issue?
Comment #18
drunken monkeyUnfortunately, as a by-product of #2772829: Make "search id" a query property instead of option we had to change the search ID assigned to Views displays, since they now have to correspond to the search display plugin ID. The patch in #8 would just revert the search ID to the previous one, thus breaking that functionality. It's therefore definitely not the correct fix here.
The problem seems to be that the Facets module still isn't using Search API display plugins to determine the available search pages, but has hard-coded logic to translate Search API Views displays to facet sources – which are, however, still using the old search IDs, as used before #2772829: Make "search id" a query property instead of option.
A quick fix would be to update the facet source plugin IDs to reflect the new format for search view page displays.
The correct fix, I think, would be to have a general Search API facet source class (not Views-specific) and use the list of existing search display plugins to derive all facet sources from that. I thought there was already an issue for that, but I can't find it right now.
Comment #19
borisson_This is the quickfix mentioned in #18.
Comment #20
borisson_Comment #21
borisson_Looks like the "quick fix" is not really that quick and we should do this "The right way", I hope to be able to figure this out today.
Comment #22
borisson_This is the work I did on this yesterday.
Comment #23
borisson_Fixes some of the core search issues.
Comment #24
borisson_Comment #25
borisson_Comment #26
borisson_It looks like
search_api_facets
option is not set on the query.Comment #27
borisson_Comment #28
borisson_Comment #29
borisson_Comment #30
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedWith #29 facets are displayed when I recreate all the facets.
When I export the facet config it changes these 2 keys:
This causes an
[ERROR] Configuration objects (facets.facet.myfacet) provided by my_search have unmet dependencies
So I updated all facet_source_id to 'views_page:search__page_1' and removed the dependencies to 'views.view.search__page_1'.
Comment #31
borisson_It looks like this doesn't support REST displays or block displays yet, which is probably the reason for the remaining failures.
Comment #32
borisson_Comment #33
borisson_I'm giving up for today, this has defeated me.
Comment #34
sam0971 CreditAttribution: sam0971 at iO commentedTested the patch from #32 in combination with search_api-8.x-1.0-beta1 and search_api_solr-8.x-1.0-alpha6 in a views page display.
The facets are working and not disappearing.
Comment #35
borisson_Awesome, thanks for testing that Sam.
That means that the page are back to working as expected. So we "just" have to fix behavior for blocks and rest pages, the Search API portion of that work is being done in #2799475: Support block and rest displays in the display deriver
Comment #36
borisson_Currently failing on search-api-beta1:
-
Drupal\rest_facets\Tests\RestIntegrationTest
(still failing)-
Drupal\facets\Tests\IntegrationTest::testFramework
(fixed with Search API patch)-
Drupal\facets\Tests\IntegrationTest::testBlockView
(still failing)-
Drupal\facets\Tests\IntegrationTest::testOnViewRemoval
(still failing) - needs to fixed in search api, too much caching on the deriver - I think.-
Drupal\facets\Tests\UrlIntegrationTest::testUrlIntegration
(fixed with Search API patch)This means that the page things are all working as they're supposed to. We need to fix the other displays though, I'm not sure if that's to be fixed here or in search api. Trying to continue work on this.
Comment #37
borisson_I'm giving up on this for today, hopefully I can figure it out tomorrow.
Comment #38
borisson_Comment #39
borisson_This fixes
Drupal\facets\Tests\IntegrationTest::testBlockView
by disabling "Hide facet when facet source is not rendered".So Drupal\rest_facets\Tests\RestIntegrationTest and Drupal\facets\Tests\IntegrationTest::testOnViewRemoval still need to fixed.
Comment #40
borisson_In #36, I said:
I fixed the RestIntegrationTest. testBlockView was fixed w/ the previous patch, so still the OnViewRemoval test to fix.
Comment #41
mkalkbrennerI keep my fingers crossed. Run test bot, run :-)
Comment #42
borisson_So I just ran the IntegrationTest again on the plane and I think everything is ok now. However we still need the search api patch. Not sure how to proceed from here. Running all tests again on my local machine to confirm that everything is resolved.
Comment #43
borisson_This should fix the facet source integration test and now all tests are green again locally.
I feel quite happy with this, I'll review this patch again and I'll see if nothing slipped in that's not needed.
I don't think that we can commit this just yet though - since the search api patch needed to make this work is not in a tagged release yet.
Comment #44
borisson_Some cleanup of the patch. Now I'm going to try to reach @drunken monkey to see what to do next.
Comment #45
borisson_so, we also need #2799475: Support block and rest displays in the display deriver, I almost forgot about that. That one still has failing tests though.
Comment #46
Nick_vhAlways good to put, in comments, the reason why this is a double underscore. Reading the code, whomever is making changes won't get why this was done.
Can we get a bit more comments here what this is doing exactly? I suppose it deletes facets from entities that are being deleted.
Also, are there places where this could fail? We have to be very robust here as this could completely break a site.
For example, check if there are definitions and if this is really an array.
Check if this will return the facetManager
Same, make sure this is really a list. And perhaps catch errors?
Also needs comments on the reason why this is needed.
should we check for errors here? Is there any way this can go wrong?
Comment #47
Nick_vhComment #48
borisson_.7 shouldn't be able to fail. Other things are addressed.
Comment #49
borisson_Also attributing Nick for help on this during the sprint.
Comment #50
borisson_Also tagging this w/ dublin's tag.
Comment #51
Nick_vhComment #52
stephen-cox CreditAttribution: stephen-cox at Agile Collective commentedI have tested patch 51 and have found a problem. With the patch, the facet list displays when I first visit a view page showing results from a Search API index, and continue to be displayed while facets are selected, but if I clear all facets then all the listed facets disappear. The facet list shows up again after doing a cache rebuild.
This has been tested with a clean Drupal 8.1.10 install with the latest dev versions of Search API, Search API Solr and Facets modules. The same behaviour can been seen using the database backend as well as the Solr backend.
Comment #53
borisson_Not sure if we should try to resolve that in this issue. I'll try to reproduce this.
Comment #54
stephen-cox CreditAttribution: stephen-cox at Agile Collective commentedThe problem I found is introduced with the patch - although the caching issue might be related to something else. I'm in Dublin and happy to help with this if I can.
Comment #55
borisson_Oh, we're in the sprintroom right now, come and find us at the search api table!
Comment #56
borisson_I've been trying to reproduce this, with a fresh 8.1 download w/ search_api's latest HEAD and database db and the patch in #51 applied.
I can't seem to do that.
Comment #57
stephen-cox CreditAttribution: stephen-cox at Agile Collective commentedSteps to reproduce the problem:
- Fresh Drupal 8.1.10 site install with latest dev versions of Search API and Facets
- Patch Facets with patch #51
- Enable search_api, search_api_database and facets
- Add tags taxonomy as a field to basic page and add the following tags: a, b, c
- Create a few basic pages and articles tagged with tags
- Create a new search API database server
- Create a new index, using content as the data source and the database server
- Add 'Title' and 'Tags » Taxonomy term » Name' to the index and index all content
- Create a new view with a page based on the search api index
- Add 'Content datasource: Title (indexed field)' and 'Content datasource: Tags » Taxonomy term » Name (indexed field)' to the view
- Create a new facet using the view as the source and 'Tags » Taxonomy term » Name' as the field
- Add the facet block to a region
- Rebuild the cache
The facet block will display, you can select facets and the view will be filtered, but if you remove all the facets then the facet block will disappear. The block will show again after rebuilding the caches.
Comment #58
borisson_Committed this as-is after running tests locally again. Hopefully the testbots will agree.
Comment #79
borisson_This works on my local machine, as well as Nick's, so no idea how to resolve this. Trying w/ debug info in the tests here.
Comment #80
borisson_Comment #82
borisson_Comment #84
borisson_Comment #85
borisson_Comment #88
borisson_Comment #90
borisson_Comment #91
borisson_Comment #93
borisson_The last test that failed on the bot is now green again locally. So now everything should green.
Comment #95
borisson_Comment #97
borisson_WOO! GREEN! WOOOOOOO
Comment #124
borisson_Was already committed.