I updated to version 2.8 and am getting the following runtime error:
Warning: Illegal string offset 'year' in date_select_element_value_callback() (line 437 of /var/www/drupal-7.27/sites/all/modules/date/date_api/date_api_elements.inc).
Warning: Illegal string offset 'month' in date_select_element_value_callback() (line 437 of /var/www/drupal-7.27/sites/all/modules/date/date_api/date_api_elements.inc).
Warning: Illegal string offset 'year' in drupal_array_set_nested_value() (line 6618 of /var/www/drupal-7.27/includes/common.inc).
I believe the warning about common.inc is caused by the date issues before it.
I'm getting these errors for a View page that has a date filter field configured as attached image...
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | views-raw-exposed-input-2315365-17.patch | 554 bytes | alexdmccabe |
| #14 | views-raw-exposed-input-2315365-14.patch | 554 bytes | alexdmccabe |
| Screen Shot 2014-08-04 at 12.32.03 PM.png | 19.73 KB | monaw |
Comments
Comment #1
monaw commentedOk, after some debugging, it appears that the problem is caused by the date_select_element_value_callback() function getting a string (eg "2014-03") for the $input parameter and then handing that parameter to the date_select_input_date() function which expects $input to be an array. This seems like a pretty fundamental functionality for the Date module...
It would be helpful if the date_select_element_value_callback() function is better documented as to the parameters it expects and what is returned.
Comment #2
monaw commentedHmm, I did a quick test and made the $input into an array but that didn't fix my problem...
Please help!
Comment #3
jennifer.chang commentedI believe it's a PHP 5.4 compatibility error.
Comment #4
damienmckennaAm hitting this error with PHP 5.3.3.
Comment #5
damienmckennaFYI the problem persists in the current -dev release (7.x-2.9-beta2+1-dev).
Comment #6
damienmckennaFYI in my case the view works fine on initial load, the error only shows when loading page 2 and only happens if an exposed filter for a date field is passed a value.
Comment #7
damienmckennaA little more info:
Comment #8
damienmckennaWhen the form is loaded first, the $input argument to date_select_element_value_callback() is an array:
When the form is submitted, $input gets passed as a string instead: '2014'
Comment #9
damienmckennaI've noticed that the problem doesn't happen if I just manipulate the filters, it is only triggered when I use the pager.
Comment #10
damienmckennaI traced it back a bit further, and it isn't just the pager. The exposed filter is built correctly, so the date field has the proper name attribute on the date selector, e.g. "date_filter[value][year]" for the year value. However, inside Views it is using a string value for the date field's default value in the 'exposed_raw_input' array in the $view object inside template_preprocess_views_view(). So it seems that the translation from string to array isn't happening like it should be.
Comment #11
damienmckennaSo I ended up resolving this by using a preprocess function to fix the value being passed to the pager:
I've already spent far too long digging into this problem for this site, this bandaid is sufficient for now but obviously it doesn't actually fix the issue.
Comment #12
Lostboy22 commentedTry logging out and restarting your browser.
If you changed the "Remember last selection", value or removed and recreated the same filter, there is a session cookie that does not get set/cleared.
Comment #13
damienmckenna@Lostboy22: On this view I don't have the 'remember' option enabled for any of the exposed fields.
Comment #14
alexdmccabeAs far as I can tell, this is actually an issue with Views. Uploading a patch.
The exposed input itself is fine, but the way Views is building the pager it's not properly looking at the exposed input.
Comment #15
damienmckenna@alexdmccabe's patch resolves the problem I was experiencing on a site and makes the URLs shorter on the initial page because it isn't passing the exposed filter's default values to the pager. Thanks for solving the problem!
Comment #16
colanWe've recently switched our testing from the old qa.drupal.org to DrupalCI. Because of a bug in the new system, #2623840: Views (D7) patches not being tested, older patches must be re-uploaded. On re-uploading the patch, please set the status to "Needs Review" so that the test bot will add it to its queue.
If all tests pass, change the Status back to "Reviewed & tested by the community". We'll most likely commit the patch immediately without having to go through another round of peer review.
We apologize for the trouble, and appreciate your patience.
Comment #17
alexdmccabeRe-uploading patch to get tests to run per #16.
Comment #18
alexdmccabeChanging back to RTBC, again per #16.
Comment #19
damienmckennaComment #21
damienmckennaCommitted. Thanks!