Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Editing a node with an empty date field produces the following:
- Warning: Illegal string offset 'value' in date_combo_element_process() (line 295 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Warning: Cannot assign an empty string to a string offset in date_combo_element_process() (line 295 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Warning: Illegal string offset 'value' in date_local_date() (line 145 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Notice: Uninitialized string offset: 0 in date_local_date() (line 145 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Warning: Illegal string offset 'value' in date_combo_element_process() (line 298 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Warning: Cannot assign an empty string to a string offset in date_combo_element_process() (line 298 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Warning: Illegal string offset 'value2' in date_combo_element_process() (line 295 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Warning: Cannot assign an empty string to a string offset in date_combo_element_process() (line 295 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Warning: Illegal string offset 'value2' in date_local_date() (line 145 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Notice: Uninitialized string offset: 0 in date_local_date() (line 145 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Warning: Illegal string offset 'value2' in date_combo_element_process() (line 298 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
- Warning: Cannot assign an empty string to a string offset in date_combo_element_process() (line 298 of /htdocs_20161220/sites/all/modules/date/date_elements.inc).
Steps to reproduce:
- Add a date field to a content type.
- Create a new node of that type.
- Edit the newly created field.
Comment | File | Size | Author |
---|---|---|---|
#48 | 2843367-php71-string-offset-47.patch | 614 bytes | artem0793 |
Comments
Comment #2
RemyAroundTown CreditAttribution: RemyAroundTown commented$element['#default_value'] can be an empty string but is used as a multi-level array. In previous versions of PHP this would not throw a warning.
The attached fix checks for an empty element that is not an array and assigns an empty array if required.
Comment #3
RemyAroundTown CreditAttribution: RemyAroundTown commentedComment #4
RemyAroundTown CreditAttribution: RemyAroundTown commentedAnd as soon as I queue the test I realize it won't pass in php 5.3 due to my use of []. Here's a more backwards compatible patch.
Comment #6
glynster CreditAttribution: glynster commentedI can confirm this patch does resolve the issue for me using php7.1. I am not sure what needs to be adjusted to get this to pass. +1 from me regardless. RTBC
Comment #7
RemyAroundTown CreditAttribution: RemyAroundTown commentedIt looks like the module itself is failing tests, so that might be another issue that should be cleared up. I'm going to bump the status of this one.
Comment #8
matthiasm11 CreditAttribution: matthiasm11 at MM-Experience commentedPatch #4 looks fine, thanks.
Comment #9
oadaeh CreditAttribution: oadaeh at Hook 42 for Zicasso, Inc. commentedI'm just making it a little easier to scan through the error notices in the summary.
Comment #10
johnzzonPatch #4 working fine for me as well.
Comment #11
robertgarrigos CreditAttribution: robertgarrigos commentedpatch #4 worked for me also.
Comment #12
DamienMcKennaI've re-queued the tests, lets see how this does.
Comment #13
DamienMcKennaComment #14
DamienMcKennaComment #15
DamienMcKennaSo the tests still fail with 7.0 and 7.1, would someone care to look at them?
https://www.drupal.org/pift-ci-job/635955
https://www.drupal.org/pift-ci-job/635956
Comment #16
DamienMcKennaI opened #2865376 so we can look into PHP 7 issues in general.
Comment #17
oadaeh CreditAttribution: oadaeh at Hook 42 for Zicasso, Inc. commented#2865376: Resolve PHP 7.0, 7.1 errors
Comment #18
DamienMcKennaBumping to 2.11.
Comment #19
Liam MorlandComment #20
Liam MorlandSorry, already linked.
Comment #21
alesr CreditAttribution: alesr commentedI did some debugging and the tests are not failing because of this patch.
The problem is in getting the site content to assertText on.
For example: $this->drupalGet('admin/structure/types/manage/story/fields'); (line 78 in date_tools.test)
The content is empty when returned from CURL.
Running tests without the patch also returns the same fails.
Comment #22
alesr CreditAttribution: alesr commentedI was still getting errors on some specific edit pages.
After a closer look I found out the condition set in patch (with &&) is wrong.
If '#default_value' index in $element['#default_value'] is not set, empty($element['#default_value']) with be true and it will go to the next check which is !is_array($element['#default_value']). In this check '#default_value' doesn't exist and will return a notice/error.
Here's a patch that fixes this.
The correct condition should be OR (||).
If default_value is empty/not set OR not an array...
Comment #24
alesr CreditAttribution: alesr commentedAs mentioned in #21, the tests are failing even without any patch from this issue so that needs to be addressed outside this issue.
I will set it to "Needs review".
Comment #25
joelpittet@alesr, #22 doesn't apply, the tests are showing that, you may not be creating against the 2.x-dev branch?
I'm re-uploading the RTBC'd #4
Comment #26
alesr CreditAttribution: alesr commentedReroll of #4 still has the same issue I mentioned in #22 description.
Here's the new patch which fixes this issue.
Comment #27
Majdi CreditAttribution: Majdi as a volunteer commentedWorks for me
Comment #28
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedPatch #26 is also fixing the issue for me on PHP 7.1. I'm not sure about the testbot, but when running the tests locally there is no difference between the number of passed and failed tests before and after applying the patch. So they seems to be unrelated to this particular issue.
Comment #29
ikeigenwijs CreditAttribution: ikeigenwijs commentedLooks good especially in combination with
https://www.drupal.org/node/2889636
Comment #30
ikeigenwijs CreditAttribution: ikeigenwijs commentedThe patch in this tread fixes the problem.
php7 tests are fixed in other issu
Comment #31
DamienMcKennaFYI I'm unable to reproduce this error with PHP 7.1.6, but the code makes sense so I still think it should be committed.
Comment #32
DamienMcKennaThis patch resolved the error for my local testing. +1
Comment #33
Plazik CreditAttribution: Plazik as a volunteer commentedThe patch from #26 works for me on PHP 7.1.9.
Comment #34
dchatry#26 seems to work for me also on 7.1.8
Comment #35
Novitsh CreditAttribution: Novitsh as a volunteer and at Dazzle commented+1
Comment #36
DamienMcKennaThe patch in comment #26 works perfectly in my testing with PHP 7.1.6. Thank you.
Comment #37
NancyDruGood on 7.1.10.
Comment #38
nanobyt3 CreditAttribution: nanobyt3 as a volunteer commented#26 seems to fix the issue.
+1 commit
And provide it with next release of date module.
Comment #40
DamienMcKennaCommitted. Thanks all.
Comment #42
rjensen CreditAttribution: rjensen commentedI'm getting these errors on a fresh install of Drupal 7.59 and Date. PHP 7.1.20
Comment #43
Liam MorlandWhat version of date are you running?
Comment #44
tomarnold2 CreditAttribution: tomarnold2 as a volunteer and commentedI'm seeing it, too. Date version 7.x-2.10 (latest).
Illegal string offset 'value2' in date_combo_element_process()
Applying patch 26 seems to have done the trick. Thank you!
Tom
Comment #45
Liam MorlandThe patch is not in 7.x-2.10. You need to run the development snapshot no earlier than revision a2ef952.
Comment #46
botrisMoved question to #2867810: Plan for Date 7.x-2.11 release
Comment #47
magoomby2 CreditAttribution: magoomby2 commentedI can confirm this patch does resolve the issue for me using PHP 7.1 using Drupal 7.59
Comment #48
artem0793 CreditAttribution: artem0793 at Adyax commentedHello,
Could you please check this patch.
Thanks
Comment #49
Liam MorlandIt appears likely that the patch in #48 is actually a better solution. A fix is already committed in #39.
Comment #50
DamienMcKennaThat's a reasonable point, thanks for the patch artem0793. Let's revisit this.
Comment #51
azovsky CreditAttribution: azovsky commentedThe patch in #48 is good! Working!
Thank you!
Comment #53
DamienMcKennaCommitted. Thanks again!
Comment #55
krak CreditAttribution: krak commentedThis issue starter 2 years ago. Fixed month ago and don't created fixed version? Users must look patch file and fix it in file?
What difficult to create new version with fix?
Comment #56
DamienMcKennaPlease help us get a stable release out by testing the current -dev version or the latest 7.x-2-11-beta releases. Thank you.
Comment #57
Anonymous (not verified) CreditAttribution: Anonymous commentedI don't know what happened since yesterday but today this bug had crawled up from its hole and was pushing error to node add and edit pages with date fields.
Committed patch fixed the error, thanks.
Comment #58
cobenashThanks, Commited work.
Comment #59
oranges13The patch in #48 works!
Comment #60
alysaselby CreditAttribution: alysaselby commentedI can verify that #48 worked with the following:
Date 7.x-2.10
Drupal 7.65
PHP 7.2.16
Comment #61
Liam MorlandThe patch in #48 is already committed. Use 7.x-2.11-beta2 to get it.
Comment #62
oranges13Some of us need this bugfix and cannot afford to run regression tests on our production systems! Yes it is committed but not everyone runs dev builds.
Comment #63
mdolnik CreditAttribution: mdolnik as a volunteer and commentedFYI the changes in #48's
2843367-php71-string-offset-47.patch
are also present in the patch in Issue: Error messages from date_entity_metadata_struct_getter()Comment #64
malcolm_p CreditAttribution: malcolm_p commented7.x-2.11-beta2 has resolved this issue for me as well.
Comment #65
fox mulder CreditAttribution: fox mulder commented7.x-2.11-beta2 has resolved this issue for me too.
Comment #66
AdamEvertsson CreditAttribution: AdamEvertsson as a volunteer commentedCan confirm. 7.x-2.11-beta2 made the errors disappear. Though I can't use it in production due to client agreement. Can this be part of a new stable release? If not, what can we do to make that happen?
Comment #67
FireHawkX CreditAttribution: FireHawkX commentedI just updated 3 modules on my site
(made a backup prior so I'm good), one of the modules was Date,
And now I am getting a wall of errors like the one at the top of this post...
all related to date (Illegal string offset 'value' in date_combo_element_process) line 295 and 298
If this is "CLOSED/fixed" why is it not in the latest update that just got downloaded?
(sorry if this is basic knowledge, i'm still kinda noob with all of this and learning)
I edited the date_elements.inc in notepad++ and replace the line
'#default_value' => isset($items[$delta]) ? $items[$delta] : '',
with
'#default_value' => isset($items[$delta]) ? $items[$delta] : array(),
and everything is fine once again :)
Comment #68
oranges13It's in a beta release not in stable which is the version you probably downloaded.
So to fix this you have two options: use the newest beta version (https://www.drupal.org/project/date/releases/7.x-2.11-beta3) to have the patch included, or apply patch in #48 yourself.
Comment #69
goodmuyis CreditAttribution: goodmuyis as a volunteer commentedIf you are just coming here:
The Development version released on 23 Oct 2019 fixed the issues
Comment #70
solideogloria CreditAttribution: solideogloria commentedKeep in mind that the development version has the following issue: #3016390: Change in "All day" end-of-day definition broke existing data