backdrop-contrib / search_api

Provides a generic API for modules offering search capabilities
GNU General Public License v2.0
0 stars 6 forks source link

Transliteration filter breaks indexing #26

Closed djzwerg closed 1 year ago

djzwerg commented 2 years ago

While using the transliteration filter the following error occurs during cronjob (indexing):

Warning: Illegal offset type in isset or empty in _transliteration_replace() (line 187 of /mypath/core/includes/transliteration.inc).

Error: Object of class stdClass could not be converted to string in preg_replace() (line 188 of /mypath/core/includes/transliteration.inc).

earlyburg commented 2 years ago

Please provide more detailed information regarding the error, including a stack trace if possible. In order to test this I need to know what conditions caused the issue. Thanks

djzwerg commented 2 years ago

@earlyburg which information would be helpful? I'm not able to make a stack trace. This is the only information I have for now: grafik

djzwerg commented 2 years ago

My settings: grafik

earlyburg commented 2 years ago

This is helpful. Can you please tell me what type of fields you are transliterating? Also, what kind of data are in the fields. I tested this and was not able to reproduce the error you are seeing. Thanks I will test this a bit more with an updated core, but I suspect it may be something specific to your environment. Can you also please give me a list of the contrib modules you are using and have enabled? Thanks.

djzwerg commented 2 years ago

Oh yes of course:

earlyburg commented 2 years ago

https://github.com/backdrop-contrib/search_api/releases/tag/1.x-1.0.06 Please download the latest release of this module and let me know if it resolves this issue. Thanks for your patience, I appreciate it.

djzwerg commented 2 years ago

Hi @earlyburg and thanks for your work. I'm sorry but the issue is still there: grafik

djzwerg commented 2 years ago

I've tested a bit and found out that the error always occurs even if transliteration is not enabled for any field.

earlyburg commented 2 years ago

I created a fresh install of backdrop latest release I installed the latest versions of search_api, search_api_solr search_api_pages. I set the filters exactly the way you have in your image and transliterated all fields Using a solr based server I was not able to reproduce this issue using content generated by the devel module.

Without access to your site and its code - I can't really go any further. I only have the github code at my disposal to evaluate, and when indexing content I am not seeing any php related messages.

Apologies, but I think this might be related to your site, and not a problem with this code per se.


`class SearchApiTransliteration extends SearchApiAbstractProcessor {

  protected function process(&$value) {
    // We don't touch integers, NULL values or the like.
    if (is_string($value)) {
      $value = transliteration_get($value, '', language_default());
    }
  }

}

As you can see from the class - only string data is allowed to be transliterated. It may be that what you are passing is causing the message, and not a bug in the code.` Also in our dialog you mentioned "I've tested a bit and found out that the error always occurs even if transliteration is not enabled for any field." - this indicates to me that you may be having problems that may be bigger than just a warning, as this may indicate an issue with php versions or server processing of configuration objects.

djzwerg commented 2 years ago

Well I don't use Search API Solr (only Search API and Search API DB). Maybe search_api_DB causes this issue? Is there a way to figure that out?

djzwerg commented 2 years ago

I'm using PHP 7.4.27 and MySQL 8.0.25

herbdool commented 1 year ago

The problem is this line: $value = transliteration_get($value, '', language_default());

transliteration_get() expects $langcode to be a string, but search_api is passing it the whole object with language_default().

herbdool commented 1 year ago

PR: https://github.com/backdrop-contrib/search_api/pull/40

argiepiano commented 1 year ago

I've tested this fix and it works. LGTM and ready to be committed.

argiepiano commented 1 year ago

@herbdool, since your PR is from December, and you pinged @earlyburg (without a response) 3 weeks ago... should we merge this PR? If you agree, since you provided the PR, I can do it with my new "bug squad" permissions. LMK

herbdool commented 1 year ago

@argiepiano yes, you can merge it.