backdrop-contrib / search_api

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

Unsupported operand types in... line 27 ...search_api/contrib/search_api_views/includes/handler_filter_language.inc #19

Closed ghost closed 2 years ago

ghost commented 3 years ago

Hello,

I am trying to add an ES / EN filter to a Search API custom index search view. When adding the filter via the views interface, the dialogue fails to load. The registered error is the title of the issue.

I am able to resolve (maybe?) the issue by adding to the preceding line:

if (empty($this->value_options)) { $this->value_options = array(); }

Backdrop 1.18.1 PHP 7.2.30-1 Search API 1.x-1.0.03

Thanks,

earlyburg commented 3 years ago

Hello, - I'll take a look today after work in a few hours. Thanks

earlyburg commented 3 years ago

I had a look at this and it may be caused by entity_wrapper. I will continue to debug this, can you tell me a bit more about the views filter? Also feel free to submit a pull request if you have code you want to contribute. More on this soon, thanks for your patience with this issue.

ghost commented 3 years ago

Hello again,

I am working to configure a search index on a node type with mostly standard fields. I added the node language attribute to the search index via Search API settings, then was attempting to filter on the language in the search view. This is where I received the error that "broke" the view interface. It seems the error has something to do with an attempt to add filter options to an as yet null set of options.

The fix I posted above "fixes" it in that the dialogue to choose options for the language filter (in views config) will now load, so views no longer appears "broke," but the view filter itself does not work as expected. I see no results once I have added the language filter, regardless of what options I choose (user's language, or an arbitrary value). It appears the value in the DB search index for the langcode element is being written as NULL for all content, even though it is certainly es / en for most nodes in the node table.

For now I have switched to using a language taxonomy I added to the node to filter content in the view as a workaround.

Happy to post a quick screenshot / screencast after work sometime if that's helpful.

earlyburg commented 3 years ago

Line 27 reads: $this->value_options = $options + $this->value_options; The unsupported operand types refers to the simple equation above. The operands in this instance are the values on either side of the plus sign "+" This would seem to indicate that one of the variables does not contain the type of value that can be used mathematically in an addition operation. The real question is "What is being passed into this equation". $this->value_options is either a value that can't be evaluated like an array - or an object. What should be passed is a number as the "+" sign is an arithmetic operator https://www.php.net/manual/en/language.operators.arithmetic.php

earlyburg commented 3 years ago

For this filter, can you please tell me what kind of indexed data type you are working with? /admin/config/search/search_api/overview - then look at your index fields and in the 4th column it should list the data type. Thank you, I appreciate it.

earlyburg commented 2 years ago

Closing this due to lack of activity