When I am using a view with date popup picker it works fine. But as soon as I go to page two I get this warnings.
Warning: Illegal string offset 'date' in date_popup_process_date_part() (Zeile 370 von /var/www/learnattack/src/sites/all/modules/contrib/date/date_popup/date_popup.module).
Warning: Illegal string offset 'time' in date_popup_process_time_part() (Zeile 446 von /var/www/learnattack/src/sites/all/modules/contrib/date/date_popup/date_popup.module).
Warning: Illegal string offset 'time' in date_popup_process_time_part() (Zeile 507 von /var/www/learnattack/src/sites/all/modules/contrib/date/date_popup/date_popup.module).
Warning: Illegal string offset 'date' in date_popup_process_date_part() (Zeile 370 von /var/www/learnattack/src/sites/all/modules/contrib/date/date_popup/date_popup.module).
Warning: Illegal string offset 'time' in date_popup_process_time_part() (Zeile 446 von /var/www/learnattack/src/sites/all/modules/contrib/date/date_popup/date_popup.module).
Warning: Illegal string offset 'time' in date_popup_process_time_part() (Zeile 507 von /var/www/learnattack/src/sites/all/modules/contrib/date/date_popup/date_popup.module).
Further there are no results anymore and the fields where I entered my dates are empty and time fields have a strange symbol.
I am using a view with more than one date picker.
But the problem is that $element ['#value'] is always a string and not an array - line 370 and 446.
if (!isset($element['#value']['date']) && isset($callback_values['date'])) {
$element['#value']['date'] = $callback_values['date']; //line 370
}
if (!isset($element['#value']['time']) && isset($callback_values['time'])) {
$element['#value']['time'] = $callback_values['time']; //line 446
}
Update:I think the pagination messes something up.
This is the url when I use the filter:
/admin/people/authenticated?field_firstname_value=&field_lastname_value=&mail=&status=1&field_role_value=All&field_state_value=All&field_gender_value=All&field_school_type_value=All&field_comment_value=&date_filter%5Bmin%5D%5Bdate%5D=10%2F07%2F2015&date_filter%5Bmin%5D%5Btime%5D=10%3A51&date_filter%5Bmax%5D%5Bdate%5D=10%2F25%2F2015&date_filter%5Bmax%5D%5Btime%5D=01%3A47&date_filter_1%5Bmin%5D%5Bdate%5D=&date_filter_1%5Bmin%5D%5Btime%5D=&date_filter_1%5Bmax%5D%5Bdate%5D=&date_filter_1%5Bmax%5D%5Btime%5D=&field_marketing_agreement_value=All&field_productspecific_marketing_value=All&rid_1=All&field_channel_value=
And this is the url when I use pagination to page 2:
/admin/people/authenticated?field_firstname_value=&field_lastname_value=&mail=&status=1&field_role_value=All&field_state_value=All&field_gender_value=All&field_school_type_value=All&field_comment_value=&date_filter[min]=2015-10-07%2010%3A51&date_filter[max]=2015-10-25%2001%3A47&date_filter_1[min]&date_filter_1[max]&field_marketing_agreement_value=All&field_productspecific_marketing_value=All&rid_1=All&field_channel_value=&page=1
As you can see the important part is:
Good: date_filter[min][date]=10/07/2015&date_filter[min][time]=10:51&date_filter[max][date]=10/25/2015&date_filter[max][time]=01:47
Bad: date_filter[min]=2015-10-07 10:51&date_filter[max]=2015-10-25 01:47
Comment | File | Size | Author |
---|---|---|---|
#13 | date-n2601110-13.patch | 2.02 KB | Siggy |
#12 | date-n2601110-12.patch | 2.03 KB | Siggy |
#10 | date-n2601110-10.patch | 2 KB | Siggy |
#9 | date-n2601110-9.patch | 1.62 KB | daniel_j |
|
Comments
Comment #2
Jurik CreditAttribution: Jurik commentedI updated this issue. While debugging I figured out that the pagination might be the problem.
Comment #3
Jurik CreditAttribution: Jurik commentedComment #4
DamienMcKennaThere's also #1866684: Value not inherited from parent element.
Comment #5
DamienMcKennaEvidently the bug was introduced in #2309015: views date field exposed filter default value not being added in $form_state['input'] when initially views loads and/or #2309015: views date field exposed filter default value not being added in $form_state['input'] when initially views loads.
Comment #6
DamienMcKennaI think the errors stem from not checking if $element['#value'] is an array before checking the 'date' value.
How does this work?
Comment #7
MichelleI was not able to reproduce this. These are the steps I took:
- Enabled date as well as the date popup and views integration.
- Created a content view with two exposed date filters.
- Added enough content to make it paginate.
- Entered in values in the filters and went to the second page.
It seemed to work just fine with no errors. Did I miss anything?
Comment #8
torgosPizzaI think this might be a duplicate of #2843367: String Offset errors on edit page using PHP 7.1.0.
Comment #9
daniel_j CreditAttribution: daniel_j commentedI think there was a typo in the patch attached to #6. Rather than this:
I think we want this:
The attached patch accomplishes this. Without this fix, I get zero results in every query that has an exposed date filter, because an array is being passed as a parameter to the underlying SelectQuery instead of a string.
Comment #10
Siggy CreditAttribution: Siggy commentedHad a similar issue on the time part as well, because when $element['#value'] = '' , then it can not convert it to an array anymore (in php7.x)
Not sure this is the best way.
Comment #12
Siggy CreditAttribution: Siggy commentedFixed my patch
Comment #13
Siggy CreditAttribution: Siggy commentedanother fix for my patch
Comment #14
torgosPizzaAnytime you post a new patch, you'll want to set the metadata to Needs review so the Testbot can run :)