After upgrading to 7.x.1.25 the bellow error begun:
Warning: Illegal string offset 'value' in SearchApiViewsHandlerFilterDate->query() (line 154 of ***/www/html/sites/all/modules/search_api/contrib/search_api_views/includes/handler_filter_date.inc).
Tracked this issue to
https://www.drupal.org/node/1783746
https://www.drupal.org/files/issues/2018-05-15/1783746-92--between_opera...
Outlining the issue from the change:
else {
while (is_array($this->value)) {
$this->value = $this->value ? reset($this->value) : NULL;
}
$v = is_numeric($this->value) ? $this->value : strtotime($this->value, REQUEST_TIME);
if ($v !== FALSE) {
$this->query->condition($this->real_field, $v, $this->operator, $this->options['group']);
}
}
$value = isset($this->value[0]) ? $this->value[0]['value'] : $this->value['value'];
$v = is_numeric($value) ? $value : strtotime($value, REQUEST_TIME);
if ($v !== FALSE) {
$this->query->condition($this->real_field, $v, $this->operator, $this->options['group']);
}
Output from this variable just before the error:
SearchApiViewsHandlerFilterDate Object
(
[value] => Array
(
[0] => 2018-10-01
)
It seems that the structure of the object is different than anticipated in the change done.
The fix I used and works for me, but not sure if it should be rolled back to the way it was.
-- $value = isset($this->value[0]) ? $this->value[0]['value'] : $this->value['value'];
++ $value = isset($this->value[0]) ? $this->value[0] : $this->value;
Also there is an empty line to be removed on line 160.
Using datepicker for the date selection.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3003742-5--unset_views_date_value.patch | 998 bytes | drunken monkey |
Comments
Comment #2
kpolychr commentedComment #3
kpolychr commentedComment #4
jelle_sComment #5
drunken monkeyThanks for reporting!
As always, it’s very hard to tell what’s really going on in Views. So, when fixing this, we should probably just opt for the maximum in safety we can get here – see the attached patch. Please test/review!
Comment #6
markabur commentedThanks, #5 works for me. Before, I was getting the error in the OP, and date-based searches returned nothing. Now the site is back to working again.
Comment #7
Anonymous (not verified) commentedPatch #5 helped me also.
The issue
'Warning: Illegal string offset 'value' in SearchApiViewsHandlerFilterDate->query() (line 154 of .... /search_api/contrib/search_api_views/includes/handler_filter_date.inc).'is gone!Thanks.
Comment #9
drunken monkeyThanks a lot for reporting back! Glad to hear this fixed the error for you.
Committed.
Thanks again, everyone!