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:

  1. Install drupal with standard profile.
  2. Add modules search_api and elasticsearch_connector modules, including composer dependencies.
  3. Install and enable search_api, elasticsearch_connector and search_api_db modules.
  4. Add your elasticsearch cluster (/admin/config/search/elasticsearch-connector/cluster/add).
  5. Add search-api server (/admin/config/search/search-api/add-server).
  6. 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

mErilainen created an issue. See original summary.

javivf’s picture

I 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 :/

juampynr’s picture

Status: Active » Postponed (maintainer needs more info)

Can anyone provide a list of steps to reproduce this from a clean Drupal installation?

javivf’s picture

Steps to reproduce :

  • install drupal with standard profile
  • add modules search_api and elasticsearch_connector
  • enable/install search_api, elasticsearch_connector and search_api_db
  • 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 diferents 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.
javivf’s picture

Status: Postponed (maintainer needs more info) » Active
m4olivei’s picture

Issue summary: View changes

Tried the steps to repro, can confirm the issue. Updated description to be more complete.

dakku’s picture

++ Same issue.
Disabling the search_api_db module and removing the DB backend server fixes the issue.

imperator_99’s picture

I can confirm that disabling the search_api_db module resolved this issue.

davidwhthomas’s picture

Status: Active » Needs review
StatusFileSize
new647 bytes

I had the same Exception: Serialization of 'Closure' is not allowed in serialize() error without the search_api_db module enabled. I was however using the search_api_solr integration 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.

javivf’s picture

Status: Needs review » Reviewed & tested by the community

It works for me, thanks davidwhthomas :)

bdlangton’s picture

I was in the same boat as davidwhthomas. I didn't have search_api_db enabled, but I did have search_api_solr enabled and was getting the issue. His patch fixed the issue for me. Thanks!

id.aleks’s picture

+1 Thanks for the patch. It resolved the issue for me.

  • skek committed 74e5833 on 8.x-5.x authored by davidwhthomas
    Issue #2904033 by davidwhthomas, javivf, mErilainen, m4olivei, juampynr...
skek’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for the work here!

Status: Fixed » Closed (fixed)

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