Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
13 Jun 2017 at 05:53 UTC
Updated:
26 Jan 2019 at 16:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
ayesh commentedComment #3
ayesh commentedComment #4
ayesh commentedComment #5
ayesh commentedComment #6
jamesoakleyThanks for working on this.
Your issue summary speaks of warning notices being thrown "here and there", whereas your patch only addresses form.inc. Was that deliberate?
So: Your patch definitely helps the issue on the site I tested it on. But I'm still getting a lot of these:
Parameter must be an array or an object that implements Countable in theme_table() (line 2061 of {site_root_path}/includes/theme.inc).I'll mark this back as Needs Work, but if the warning above is a genuinely different issue it can instead go RTBC, and I'll open a separate issue about theme_table in theme.inc
Comment #7
ayesh commentedThanks for the review @JamesOakley. I mentioned (with poor choice of words of course :) ) "here and there" because it's difficult to track-down when count() was used against uncountable values.
\_form_validate()function was one, but I found 2 more notices including the one you mentioned. Same error was triggered at line 1998 of that file (as of6336b7177eaf1b93).I'm attaching a new patch. I'd truly appreciate any reviews.
Thank you.
Comment #8
David_Rothstein commentedThere's a patch at #2932916-7: [PHP7] Warning: count(): Parameter must be an array or an object that implements Countable in PHP 7.2 that could perhaps be combined with this one.
For the form.inc changes, any reason for the subtle differences between this patch and what was committed to Drupal 8 in #2915820: [PHP 7.2] FormValidator: Parameter must be an array or an object that implements Countable?
Comment #9
joseph.olstadphp 7.2 compatibility very close. I created a related issue to test php 7.2 compatibility with this issue fix and also the each fix in #2925449: [PHP 7] Function each() is deprecated since PHP 7.2 [D7] only one test failure , although I am unsure why. would take some debugging.
here: #2947772: Fully support PHP 7.2 in Drupal 7
combined patch 7 above with patch from the other issue
#2925449-55: [PHP 7] Function each() is deprecated since PHP 7.2 [D7]
Comment #10
fabianx commentedCode needs work per #8.
Comment #11
joseph.olstad#8 is referring to the revert commit.
The actual D8 commit David Rothstein refers to is
https://cgit.drupalcode.org/drupal/commit/?id=c6d6c4d
I've attempted to make these changes. as I interpret them.
Comment #12
joseph.olstadthe roll up all patch was off of the interdiff, oops.
here it is again corrected.
Comment #13
joseph.olstadComment #14
joseph.olstadtry again
Comment #15
joseph.olstadpatch #7 looks like the best solution
I tried the suggestion in #8 , but it caused form errors. Whereas patch #7 has no form errors.
Comment #16
joseph.olstadof note
in patch 14 I changed this:
Didn't seem to make a difference, but maybe we don't have enough theme test coverage for that. as there is a count() on those items but they're apparently already countable (or arrays) because no issue there.
and also
Patch 7 doesn't have this, however it doesn't seem to change the test results as they're apparently already countable (or arrays) because no issue there either afaik.
The 7.2 rollup issue (referenced) only has 1 failure left, and it appears to be unrelated to patch 7.
Patch 7 is an improvement, we can start with that.
I suggest we move forward and attack the one single error that remains
#2947772: Fully support PHP 7.2 in Drupal 7
so commit patch 7 (or something close to it)
and commit RTBC patch 106 here:
#2925449-106: [PHP 7] Function each() is deprecated since PHP 7.2 [D7]
and then focus on the remaining issue in:
#2947772: Fully support PHP 7.2 in Drupal 7
Comment #17
joseph.olstadI'd go with #7 here by Ayesh.
Crack open a bottle of bubbly! php 7.2 now passing all tests.
Great work everyone!
See:
#2947772: Fully support PHP 7.2 in Drupal 7
ready for commit
Comment #18
fabianx commentedThis needs to be actually used.
See:
https://cgit.drupalcode.org/drupal/commit/?id=c6d6c4d
Can someone find out why D8 added this?
This needs a comment in why this is necessary - as it looks strange without context:
When does this even happen and why?
Was this changed in D8 in the same way or is it different here, because of the Twig conversion?
Comment #19
sjerdo@Fabianx #18:
#18.1
$is_empty_null was added since $is_empty_multiple no longer equals TRUE when $element['#value'] is NULL.
Not adding this condition will allow required fields to have NULL values without setting a form error message.
#18.2
Looking at function template_preprocess_table in D8 it seems D8 checks if the arrays contain values by using !empty($variable) instead of count($variable). This seems logic since the count() method is only called for checking if the array contains any value. Using count instead of !empty has overhead (it unnecessarily counts the array items while we just need to check if the array contains any item).
Default values in D7 in common.inc contain NULL:
The default value for items in item_list is an empty array:
Updated the patch for #18.1 and #18.2
Comment #20
sjerdoComment #21
fabianx commentedGreat work!
Don't we need to add the is_null check also to the 2nd conditional check like in Drupal 8?
Comment #22
sjerdo@Fabianx #21
Doesn't seem so.
D8 (source) first sets
$elements['#required_but_empty'] = TRUE;, then triggers element_validate validators and finally checks the statement again to set the 'field is required' error. Whereas D7 (source) directly sets the 'field is required' error and then triggers element_validate validators.Comment #23
fabianx commentedOkay, great.
If someone else could RTBC this, I can give it a final committer review and make it ready for commit ;).
Comment #24
bahson commentedGreat #joseph.olstad patch 20 got all the error and logs gone
Comment #25
joseph.olstad@Bahson, do you mean patch 19 by @sjerdo ? there is no patch 20 here in this issue?
**EDIT**
We should now go with patch 19 by @sjerdo as it has adjustments made as recommended by FabianX
the patch I uploaded in comment #14 is not good, it is hidden for that reason.
Comment #26
fabianx commentedAs I said: If I were to RTBC it, I can't commit it technically ;), so if someone could test it and review it and give it community blessing we can get PHP 7.2 support sorted.
Comment #27
joseph.olstadRTBC Patch #19. One step closer to getting php 7.2 tests going on the contrib modules. As soon as we get these related patches into core I'll start adding php 7.2 tests for the modules I have access to like media, file_entity , i18n, webform_localization, exif_custom, and as many other contrib modules as possible. Once this is in, we can start making noise in the ctools queues and views queue and the rest of contrib land so that we can get contrib ready for 7.2 asap.
Very satisfied with the progress in D7 core, just two other related 7.2 patches and we're off to the races.
we need:
#2925449: [PHP 7] Function each() is deprecated since PHP 7.2 [D7]
AND
#2946045: Unable to update modules due to Archive_Tar incompatibility with PHP 7.2
Comment #28
fabianx commentedThis is pending commit
Comment #29
fabianx commentedCommitted and pushed to 7.x. Thanks!
Comment #32
David_Rothstein commentedI think this broke PHP 5.2 compatibility -- not sure there are that many people who care at this point, but it's still officially supported. Can we fix via the attached?
Comment #33
fabianx commentedOf course
Comment #34
ksujitha18 commentedThanks a lot @David_Rothstein. your patch worked perfectly. But I have applied this for Drupal core 7.6 version.
Comment #35
farnoosh commentedCannot apply patch #32 to Core 7.60! The form.inc file has changed on 7.60
Comment #36
ayesh commentedI suppose you can apply the patch that was committed to 7.x branch, and rebased after the 7.60 was released. Try this patch: https://cgit.drupalcode.org/drupal/commit/?id=73e12f0 (or use 7.x branch which is easier).
Comment #37
joseph.olstadRather than patch, the easiest thing to do (if you have drush) is upgrade to D7 core version 7.x dev as follows:
Comment #38
farnoosh commentedThanks, Patch #19 works on core 7.60.
Comment #40
fabianx commentedBack to fixed
Comment #42
joseph.olstadFYI, I've created a new issue for support of PHP 7.3.
#3028648: Fully support PHP 7.3 in Drupal 7