PATCH FOR THIS IS ATTACHED:
Use case:
The following warning and notices show up in watchdog when a date facet is not used: (facet by department or category for example, not date)
Warning: Missing argument 2 for date_facets_get_ranges(), called in modules/contrib/date_facets/lib/Drupal/Apachesolr/Facetapi/QueryType/DateRangeQueryType.php on line 100 and defined in date_facets_get_ranges() (line 91 of modules/contrib/date_facets/date_facets.module).
Undefined index: [2014-01-01T00:00:00Z TO 2015-01-01T00:00:00Z] in _date_facets_api_facet_create_label() (line 75 of modules/contrib/date_facets/date_facets.module).
Undefined index: index id in _date_facets_api_facet_create_label() (line 65 of modules/contrib/date_facets/date_facets.module).
Undefined index: field in _date_facets_api_facet_create_label() (line 65 of modules/contrib/date_facets/date_facets.module).
See attached patch.
Comments
Comment #1
joseph.olstadAdded patch with appropriate name.
Patches date_facets.module
and also lib/Drupal/Apachesolr/Facetapi/QueryType/DateRangeQueryType.php
Comment #2
joseph.olstadComment #3
joseph.olstadComment #4
joseph.olstadCleaned up debugging code
Please review this patch.
Comment #5
joseph.olstad(formatting change to patch)
added a space after , and before NULL parameter
Comment #6
joseph.olstadredid patch to make sure it works on latest dev build.
Comment #7
joseph.olstadI've been running this patch for a couple weeks, no issues.
Comment #8
eugene.ilyin commentedHello
I'm using Search API
I cannot reproduce notices when I'm using this
Comment #9
eugene.ilyin commentedComment #10
eugene.ilyin commentedComment #11
eugene.ilyin commentedI've tried to reproduce it again but I haven't any errors when I'm using other facets (facet by string in my case).
I'm closing this issue. Don't hesitate to open it again if you'll have problems.
Comment #12
eugene.ilyin commentedComment #13
joseph.olstadFixed as in "committed" or fixed as in "cannot reproduce"?
In my site, I have two languages and entity translation with field translation enabled. As well we're using the i18n module for string translations of labels and such. Might be the reason why we needed the patch.
If you look at the code of the patch, a couple isset calls , very low risk type of stuff.
Comment #14
eugene.ilyin commentedfixed as "cannot reproduce".
I agree, but we shouldn't use isset just to use it. Please provide step by step algorithm - how I can reproduce this problem.
Comment #15
joseph.olstadHi Eugene, unfortunately getting the steps to reproduce would be very difficult for me. I am no longer working on any sites that use date facets.
With that said, if no one else has responded, perhaps the issue is mitigated by recent improvements to the module or else perhaps just very few people are using date facets with multilingual drupal site configurations.
Either way, someone may stumble across this patch in the future.
The other likelihood is that most people ignore their watchdog and let their watchdog pile up with warning messages without dealing with them.
Comment #16
eugene.ilyin commentedHi Joseph.
For me too :)
So, I'll be happy if somebody will submit algorithm and patch.