When using Date Popup calendar and choosing time skip option, an "Undefined index" warning occurs on a scheduled node save. This occurs only when date_popup module is used together and there's no problem for the functionality.
Notice: Undefined index: time in scheduler_date_popup_pre_validate_alter() (line 917 of /drupal_root/sites/all/modules/contrib/scheduler/scheduler.module).
The steps to reproduce:
1. Set up Drupal 7.43.
2. Install and enable Scheduler and Date (date_popup) modules.
3. Use "Date Popup calendar" and "Allow users to enter only a date and provide a default time" option. The page path is `/admin/config/content/scheduler` .
4. Enable Scheduling function on a content type. For example, Article. The page path is `/admin/structure/types/manage/article`.
5. Create a node with "Publish on" date.
6. Check the log. You can see the above warning.
Comment | File | Size | Author |
---|---|---|---|
#2 | scheduler-fix_undefined_time_index_warning-2712779-1.patch | 945 bytes | hgoto |
|
Comments
Comment #2
hgoto CreditAttribution: hgoto as a volunteer and at Studio Umi commentedHere is a patch to solve this warning. The index is not always available and `empty()` should be used here. The module for Drupal 8 doesn't implement the same function (integration with Date Popup). So I created a patch only for Drupal 7. I hope someone would review this. Thank you.
Comment #3
hgoto CreditAttribution: hgoto as a volunteer and at Studio Umi commentedAdditional information: this phenomenon can be seen in the current latest version 7.x-1.4.
Comment #4
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHello hgoto,
Thanks for the detailed explanation. However, it is strange that you have this error, because I do not get it. There must be something different between our drupal site setups. If I had seen this error before I would have corrected it! I have a few questions:
In my scheduler_date_popup_pre_validate_alter() I always get a 'time' value in the input array:
If you want to try it, the above debug was created using:
Comment #5
hgoto CreditAttribution: hgoto as a volunteer and at Studio Umi commentedHi jonathan1055, thank you for your reaction. I see. I'll answer the questions as much as possible.
My php version is 5.6.20.
I didn't change it. I use "Use default jQuery timepicker" which is the default one.
I don't have that. The time entry field is not displayed and only the date entry field is shown.
Probably it's because I changed the "Date format" of Scheduler field setting. (I'm sorry, I forgot to this point in the steps...)
Please visit the Scheduler settings page `/admin/config/content/scheduler` and change "Date format" field value to "Y-m-d" (delete the time part). And again, please create or edit a node. I think it's necessary to do this to reproduce the phenomenon.
The module weights are as following:
- Scheduler: 0.
- Date: 0.
- Date Popup: 0.
I didn't change the values.
...
I used the same `dd()` debug as you did. I checked the phenomenon again. Then, the 'time' key is there when I use the date format "Y-m-d H:i:s" and it's not there when I use the format "Y-m-d".
If there is any points I should share, please tell me. Thank you for your time.
Comment #6
hgoto CreditAttribution: hgoto as a volunteer and at Studio Umi commentedComment #7
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedYes, that's it. If the time part is removed then the $input array does not have 'time' key. Interestingly, the devel module backtrace has some fault in it, which means the warning was not being shown for me. When I removed the krumo backtrace display and reverted to 'standard drupal' the warning then showed up.
I will make this change. There is no corresponding fault in 8.x because currently we do not use the scheduler format for the date pop-up, and this conversion has not been decided yet.
Comment #8
hgoto CreditAttribution: hgoto as a volunteer and at Studio Umi commentedI got it. Thank you for checking and kind description!
Comment #10
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedI also took the opportunity to use
!empty()
on the date array key, as that is safer than testing for!= ''
Thank you, hgoto.
Comment #11
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedComment #12
hgoto CreditAttribution: hgoto as a volunteer and at Studio Umi commentedI see. jonathan1055, thank you for your speedy action.