Problem/Motivation
When adding a Server and there are multiple Backend's to choose from on the admin UI including Elasticsearch, choosing Elasticsearch has no effect on the Admin UI. If you check the logs, the following error is reported:
Exception: Serialization of 'Closure' is not allowed in serialize() (line 14 of /var/www/docroot/core/lib/Drupal/Component/Serialization/PhpSerialize.php).
Something similar has been fixed before in #2826804: Error when trying to create a search api server but the error is different.
Full steps to reproduce:
- Install drupal with standard profile.
- Add modules search_api and elasticsearch_connector modules, including composer dependencies.
- Install and enable search_api, elasticsearch_connector and search_api_db modules.
- Add your elasticsearch cluster (/admin/config/search/elasticsearch-connector/cluster/add).
- Add search-api server (/admin/config/search/search-api/add-server).
- You will see two different Backends to add (Database and Elasticsearch). If you click on database option you will get configuration related to this backend but if you select Elasticsearch you won't get configuration form, and the above error is logged.
Proposed resolution
Understand the exception, fix the issue.
Remaining tasks
Fix it.
User interface changes
The Add Server form should correctly toggle between Backends.
API changes
None.
Data model changes
None.
Comments
Comment #2
javivf commentedI have the same problem, if you have only elasticsearch backend enabled, you can add the server but it doesn't work if you have search_api_db module enabled (for example).
I tried an installation with search_api_db and search_api_algolia and they can coexist without problems then I assume that the problem is with SearchApiBackend plugin implementation, anyway I couldn't solve the problem yet :/
Comment #3
juampynr commentedCan anyone provide a list of steps to reproduce this from a clean Drupal installation?
Comment #4
javivf commentedSteps to reproduce :
Comment #5
javivf commentedComment #6
m4oliveiTried the steps to repro, can confirm the issue. Updated description to be more complete.
Comment #7
dakku commented++ Same issue.
Disabling the search_api_db module and removing the DB backend server fixes the issue.
Comment #8
imperator_99 commentedI can confirm that disabling the search_api_db module resolved this issue.
Comment #9
davidwhthomas commentedI had the same
Exception: Serialization of 'Closure' is not allowed in serialize()error without thesearch_api_dbmodule enabled. I was however using thesearch_api_solrintegration module, for testing.I found implementing the _sleep() method helped to prevent the fatal serialization error.
Afterwards, I could add and configure the ES server as well as create the index and query it via the Search API view.
Patch attached, with thanks for the useful module.
Comment #10
javivf commentedIt works for me, thanks davidwhthomas :)
Comment #11
bdlangton commentedI was in the same boat as davidwhthomas. I didn't have
search_api_dbenabled, but I did havesearch_api_solrenabled and was getting the issue. His patch fixed the issue for me. Thanks!Comment #12
id.aleks commented+1 Thanks for the patch. It resolved the issue for me.
Comment #14
skek commentedThank you for the work here!