When viewing the page created by search_api_solr_default module that was just added to the latest release, I'm getting an error:

Error: The views_page:solr_search_content__page_1 plugin does not exist.

..but the search field still shows up. When I go to search however, I get a fatal error (500)

PHP Fatal error: Call to a member function setConjunction() on a non-object in /var/www/docroot/modules/contrib/search_api/src/Plugin/views/filter/SearchApiFulltext.php on line 214, referer: http://192.168.99.100:32781/solr-search/content

Details:

This is a fresh installation (drush site-install config_installler) and then installing search_api_solr (alpha5), search_api(alpha16) , and search_api_solr_defaults.

CommentFileSizeAuthor
#29 2763161-29--clear_display_plugin_cache_upon_view_edits.patch4.72 KBdrunken monkey
#29 2763161-29--clear_display_plugin_cache_upon_view_edits--tests_only.patch2.41 KBdrunken monkey
#29 2763161-29--clear_display_plugin_cache_upon_view_edits--interdiff.txt1.19 KBdrunken monkey
#27 2763161-27--clear_display_plugin_cache_upon_view_edits--tests_only.patch1.98 KBdrunken monkey
#27 2763161-27--clear_display_plugin_cache_upon_view_edits--tests_only.patch1.98 KBdrunken monkey
#27 2763161-27--clear_display_plugin_cache_upon_view_edits--interdiff.txt779 bytesdrunken monkey
#23 2763161-16--clear_display_plugin_cache_upon_view_edits.patch4.35 KBdrunken monkey
#16 2763161-16--clear_display_plugin_cache_upon_view_edits.patch4.35 KBdrunken monkey
#16 2763161-16--clear_display_plugin_cache_upon_view_edits--tests_only.patch2.47 KBdrunken monkey
#16 2763161-16--clear_display_plugin_cache_upon_view_edits--interdiff.txt425 bytesdrunken monkey
#12 2763161-12--clear_display_plugin_cache_upon_view_edits.patch4.25 KBdrunken monkey
#12 2763161-12--clear_display_plugin_cache_upon_view_edits--interdiff.txt2.31 KBdrunken monkey
#11 2763161-11--clear_display_plugin_cache_upon_view_edits.patch4.1 KBdrunken monkey
#11 2763161-11--clear_display_plugin_cache_upon_view_edits--tests_only.patch2.38 KBdrunken monkey
#9 2763161-9--clear_display_plugin_cache_upon_view_edits.patch1.72 KBdrunken monkey
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

frankcarey created an issue. See original summary.

mkalkbrenner’s picture

PHP Fatal error: Call to a member function setConjunction() on a non-object in /var/www/docroot/modules/contrib/search_api/src/Plugin/views/filter/SearchApiFulltext.php on line 214, referer: http://192.168.99.100:32781/solr-search/content

I can confirm the error. It seems to be introduced lately before the release by the commit of #2064637: Add a plugin system for query parsing

mkalkbrenner’s picture

Project: Search API Solr » Search API
Version: 8.x-1.0-alpha5 » 8.x-1.x-dev
Component: Code » Views integration
Priority: Normal » Critical

Thomas, do you an idea about what's going on here or an advice about something we need to change in the Solr backend?

izus’s picture

i confirm the bug too
i tested with search_api_solr and search_api_db
it seems that every view based on an index throws the error

samtny’s picture

This appears not to be limited to Solr, as I am getting the error on a View created against a Content index with search_api_db backend.

Debugging now but I bet somebody else will patch it soon ;)

-S

drunken monkey’s picture

See #2760953-8: Notice: Undefined index: roles in ...RenderedItem->addFieldValues() – clearing the cache should help to fix a site broken that way, and a patch like the one there should fix the module in general. Pretty stupid, but seems to be necessary. (I can explain in more detail, if someone wants to know.)

FooZee’s picture

Actually I would be really interested in knowing more details about this issue. Does it appear randomly? or only once after you first enable the module?

Grimreaper’s picture

Hello,

I encountered the same issue using search_api-8.x-1.0-alpha17 and search_api_solr-8.x-1.0-alpha6

In search_api/src/Plugin/views/query/SearchApiQuery.php line 204, I debugged

$display_plugin_manager = \Drupal::service('plugin.manager.search_api.display');
$test = $display_plugin_manager->getDefinitions();

$test was effectively empty.

In search_api/src/Plugin/search_api/display/ViewsPageDisplay.php, I changed the namespace just to test (I forgot why I thought there was a problem with the namespace...).

namespace Drupal\search_api\search_api\display;

instead of

namespace Drupal\search_api\Plugin\search_api\display;

I cleared the cache.

It does not work either.

I undid the change in the namespace and cleared the cache.

Now $test is not empty and the plugin derived from the view is detected and it works...

I haven't used plugin deriver yet, but I suspect that it is not triggered when creating a new view which can be problematic.

drunken monkey’s picture

Priority: Critical » Major
Status: Active » Needs review
FileSize
1.72 KB

The attached patch should fix this problem.
I don't know anymore what I meant to say with #6. It's possible I posted this to the wrong issue, or linked the wrong issue.
The problem here is exactly as Grimreaper states: when you create/update/delete a view, the display plugin definitions won't be re-computed but loaded from cache, so the display plugin associated with the Views page cannot be found. (With #2772829: Make "search id" a query property instead of option, this would at least not crash the whole view anymore, but still lead to problems – for example, with facets.)

The attached patch should fix this: just implement the entity CRUD hooks for views in the Search API and clear the display plugin cache in them.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

This is a good fix, I believe, not sure if we'd want to have tests for this either, but that would mean we'd have to create a view trough the UI or code in the test and that seems like a lot of trouble to get this right.

drunken monkey’s picture

Tests are a good idea, and would be far less complicated than you thought: it seems between a Kernel test's setUp() method and the test methods, the cache isn't cleared automatically, so there we can easily check whether the display plugin is there.

Or, rather: "could". The static caching of derivatives in the deriver class, and of derivers in the discovery class, makes this impossible without a dirty hack like the one in the attached patch.
A much better solution would be if we were able to rebuild the container (or just our display plugin manager service), but I don't see any easy method to do this.
On the other hand, adding this method override just for the sake of a test is also a bit ugly. (Although it might also prevent problems in non-test edge cases, where display plugins are retrieved in the same page request as a view CRUD event.) In summary: I'm not sure.

Something else entirely, though: Should we maybe, before clearing the cache in the CRUD hook, check whether the view is even one of ours?

drunken monkey’s picture

The last submitted patch, 11: 2763161-11--clear_display_plugin_cache_upon_view_edits.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 12: 2763161-12--clear_display_plugin_cache_upon_view_edits.patch, failed testing.

ifrik’s picture

Tested this with alpha16 and the patch works for me.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

  • drunken monkey committed 925c861 on 8.x-1.x
    Issue #2763161 by drunken monkey: Fixed display plugin not being found...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Thanks a lot for testing and reviewing!
Committed.

  • drunken monkey committed 38ed34a on 8.x-1.x
    Revert "Issue #2763161 by drunken monkey: Fixed display plugin not being...
drunken monkey’s picture

This broke our tests, seems we need to re-visit.

drunken monkey’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 23: 2763161-16--clear_display_plugin_cache_upon_view_edits.patch, failed testing.

ifrik’s picture

The patch not only works for me for this issue, but it also fixes another cache-related issue due to which "rendered entity" are not shown as a display option #2771271: Add Views support for "users" similiar to rendered entity

drunken monkey’s picture

Title: Error: The views_page:solr_search_content__page_1 plugin does not exist. » Fix display plugin not being available right after a view or display is created
Status: Needs work » Needs review
FileSize
779 bytes
1.98 KB
1.98 KB
borisson_’s picture

Status: Needs review » Needs work

Both test-only patches pass, and I don't think they should?

drunken monkey’s picture

Oops, seems I accidentally added the tests-only patch a second time instead of adding the proper patch.
Also, as you say, it's of course not ideal if the tests-only patch passes. But I see the problem: if we don't fill the search displays cache first, the check for the display can't possibly use stale cache data.
The attached revision should now work.

borisson_’s picture

KernelTest looks great. However, I just applied this locally and reran the failing test in #2799475: Support block and rest displays in the display deriver and this doesn't resolve that.

drunken monkey’s picture

KernelTest looks great. However, I just applied this locally and reran the failing test in #2799475: Support block and rest displays in the display deriver and this doesn't resolve that.

I'd say that's a problem of the other issue.
And I think I know what that is: the plugin manager has both a static and a persistent cache. When you delete the Views display with a web request, the persistent cache will be flushed, but the static cache in the test case process can't be affected, so will continue to serve the stale data.
You'd either have to rebuild the plugin manager service (or complete container – no idea, though, how to do either of those), or manually call clearCachedDefinitions(), or delete the Views display programmatically instead of via a web request.

borisson_’s picture

If that's something that should be fixed in the other issue - I feel this can be committed.

  • drunken monkey committed fbfa0ca on 8.x-1.x
    Issue #2763161 by drunken monkey, borisson_: Fixed cache issues with...
drunken monkey’s picture

Status: Needs review » Fixed

OK, great. Thanks for reviewing!
Committed.
Thanks again, everyone!

ifrik’s picture

Thanks, that will save sitebuilders a lot of headache.

Status: Fixed » Closed (fixed)

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