Drupal 10, the latest version of the open-source digital experience platform with even more features, is here.Problem/Motivation
PHP 7.4 was released in November 2019. Drupal 7 is not yet compatible with it.
Proposed resolution
Solution broken down to various smaller issues for easier review (not necessarily in priority or dependency order):
Done:
- #3085148: Fix field_test_field_attach_delete_bundle()
- #3085098: PHP Phar Stream Wrapper should be updated (PHP7.4 support, drop fileinfo dependency)
- #3126312: Since PHP 7 func_get_args() no longer reports the original value as passed to a parameter, so call it early
- #2788565: sample code for callback_filter_process() and callback_filter_prepare() should not include deprecated regex option
- #3087121: SystemValidTokenTest is failing on PHP 7.4 when drupal_hmac_base64() is called incorrectly
- #3085151: field_ui_display_overview_form() expects to always get an array from field_info_formatter_types()
- #3125824: Trying to access array offset on value of type null in forum_get_topics()
- #3126138: taxonomy_update_7004() uses non-existent widget select
- #3126133: NumberFieldTestCase uses non-existing formatter number_float
- #3085163: Comment module causes PHP 7.4 Notices on uninstall
- #3118301: Curly brace syntax for accessing array elements and string offsets has been deprecated in PHP 7.4
- #3126140: PHP 7.4 notice in run-test.sh
- #3084943: Pass parameters as implode($glue, $pieces); reverse order is deprecated
- #3084955: Invalid characters passed for attempted conversion, these have been ignored in _color_unpack()
- #3084961: Trying to access array offset on value of type null in theme_pager/pager_first/pager_last/pager_previous/pager_next()
- #3084935: element_children() and DrupalRequestSanitizer::stripDangerousValues() should not use integer keys as array
- #3084945: Trying to access array offset on value of type null in _batch_finished()
- #3084953: Trying to access array offset on value of type null in _drupal_build_css_path()
- #3084965: Trying to access array offset on value of type bool in search_excerpt()
- #3084980: Trying to access array offset on value of type null in path_delete()
- #3085088: menu_get_item() might return FALSE; calling code should take account of this
Remaining tasks
Get all sub-issues to RTBC. Review and commit them all.
User interface changes
None.
API changes
Hopefully none. See sub-issues.
Data model changes
Hopefully none. See sub-issues.
Release notes snippet
This is the first Drupal 7 release to fully support PHP 7.4. Please test and report any bugs in the issue queue.
| Comment | File | Size | Author |
|---|---|---|---|
| #108 | 2021-02-24_09-10.png | 15.19 KB | heddn |
| #90 | 3081386-89_noop.patch | 289 bytes | mcdruid |
| #84 | 3081386-84_noop.patch | 289 bytes | mcdruid |











Comments
Comment #2
Taran2LAs PHP7.3 support is almost ready, I went ahead a bit and run tests using the latest D7 core against PHP7.4-beta4. The only patch I've added was from #3025335-3: session_id() cannot be changed after session is started
... and most of the tests fail - there are 199303 exceptions :) Actually, it's not that bad: 187911 of them are PHP notices in a single line of common.inc in
element_children()Then I've analyzed those exceptions and here is the document: https://docs.google.com/spreadsheets/d/1ROyMySRs8atpSc3dIPHCM9O2EZivNvJo...
Stay tuned for the issues!
Comment #3
apadernoComment #4
Taran2LPatch fixing some small misc issues attached
Comment #5
Taran2LUpdated patch attached:
1. Typo in NumberFieldTestCase causes PHP7.4 notice "Trying to access array offset on value of type null" in
_field_write_instance()-number_floatfield formatter does not exist2. Trying to access NULL value as array in
forum_get_topics()3. The array and string offset access syntax using curly braces is deprecated in
SearchQuery::parseSearchExpression()4. Typo in
taxonomy_update_7004()causes PHP7.4 notice "Trying to access array offset on value of type null" in_field_write_instance()-selectfield formatter does not existThis code does work only due to Options module is doing:
in
options_field_widget_form(), ie it does not matter whether it'sselectoroptions_selectComment #6
Liam MorlandThanks for the patch.
I think it is best if we keep this issue for overall tracking and have all patches in child issues about specific issues.
Comment #7
Taran2L.. and that's it - with all listed children issues + #3025335-3: session_id() cannot be changed after session is started + #3081386-5: [META] Fully support PHP 7.4 in Drupal 7 (patch from this issue) D7 was able to pass all the tests with PHP7.4-beta4
Attaching combined patch (just for testing purposes)
Comment #8
Taran2L@joseph.olstad seems like PHP7.4 testing is stuck in Queueing mode forever; probably, someone needs to take a look at DrupalCI setup?
Comment #9
joseph.olstadHello everyone, thanks for working on this php 7.4.x compatibility issue.
I've created an issue in the drupalci_testrunner queue.
Please followup here:
#3085368: Tests queued for 7 days before finally running when testing Drupal 7 with PHP 7.4
Comment #10
apadernoComment #11
joseph.olstadif we ever want to get traction on this issue someone new will have to become maintainer of Drupal core 7.x
#3086286: Offering to maintain Drupal core (@joseph.olstad)
we should have had a 7.68 release by now with the fix from
#3025335-3: session_id() cannot be changed after session is started
(among others)
Comment #12
joseph.olstadgreat work so far @Taran2L , the tests finally completed, only 6 fails!
Comment #13
Taran2LHi @joseph.olstad, thanks for pushing this. On my local machine, all tests were green ... and I've figured out why: one patch is outdated and one is missing. Find new combined patch attached
Comment #14
Taran2Lso, there is one fatal error preventing test to be completed: seems like PHP7.4 throws PHP fatal error when trying to cast stdClass object into a string, but cannot find this change record
Comment #15
Taran2LUpdates:
Comment #16
Taran2L... and the new combined patch (should be all green 5.3-7.4)
Comment #17
Taran2L.. and hopefully the last one :)
Comment #18
Taran2LYAY!
Comment #19
joseph.olstadwow, very awesome!!!
So, what next?
Comment #20
ozinCool! 😎
Comment #21
Taran2LComment #22
Taran2LOkay, the various fixed patch should be updated to incorporate changes already available in the combined version
@joseph.olstad I guess someone needs to RTBC patches (most of them are super small and obvious) and then we need to push core team to have them committed (easier to day than do I think)
Comment #23
Taran2LComment #24
sjerdo@Taran2L I guess we should move the "various fixes" to a separate issue since this issue is a Plan.
Comment #25
joseph.olstad@sjerdo the various fixes are already in seperate issues:
#3084935: element_children() and DrupalRequestSanitizer::stripDangerousValues() should not use integer keys as array
#3084943: Pass parameters as implode($glue, $pieces); reverse order is deprecated
#3084945: Trying to access array offset on value of type null in _batch_finished()
#3084953: Trying to access array offset on value of type null in _drupal_build_css_path()
#3084955: Invalid characters passed for attempted conversion, these have been ignored in _color_unpack()
#3084961: Trying to access array offset on value of type null in theme_pager/pager_first/pager_last/pager_previous/pager_next()
#3084965: Trying to access array offset on value of type bool in search_excerpt()
#3084980: Trying to access array offset on value of type null in path_delete()
#3085088: menu_get_item() might return FALSE; calling code should take account of this
#3085098: PHP Phar Stream Wrapper should be updated (PHP7.4 support, drop fileinfo dependency)
#3085148: Fix field_test_field_attach_delete_bundle()
#3085151: field_ui_display_overview_form() expects to always get an array from field_info_formatter_types()
#3085163: Comment module causes PHP 7.4 Notices on uninstall
#3087121: SystemValidTokenTest is failing on PHP 7.4 when drupal_hmac_base64() is called incorrectly
Comment #26
Taran2L@joseph.olstad, I believe @sjerdo would like to move patch from #22 into the separate issue and leave this one with combined version only. Totally fine with that
Comment #27
apaderno@Taran2L Actually, no. This issue is a plan, which don't need any patch, not even a combined one.
The related issue contains the patches, and those patches will be committed, one by one. Core maintainers will not commit a combined patch.
In the past, to make it clearer, [META] was added at the beginning of the issue title.
Comment #28
apadernoSee comment #6.
Comment #29
apadernoComment #30
joseph.olstadComment #31
joseph.olstadComment #32
joseph.olstadphp 7.4 compatibility patches are also 'almost' ready D8.9.x
Please continue reviewing the related D7 issues for php 7.4.x compatibility.
Thank you
Comment #33
joseph.olstadAmazing work Taran2L, thanks again!
Comment #34
apadernoComment #35
joseph.olstad@Taran2L great work.
PHP 7.3 is working nicely now with core 7.69
Looking forward to getting your patches into the 7.x-dev branch so that we can give it a good head start on readiness with contrib testing and the rest.
Comment #36
ronlee CreditAttribution: ronlee commentedOK, team! :)
Let's get @Taran2L code added to drupal core, so the community can benefit from PHP 7.4!
Thanks, everyone.
You're all doing excellent work.
Comment #37
Gábor HojtsyRetitle for accuracy. Looks like various issues still need review and some are needs work. Updated issue summary, and transported list of child issues from #25 to issue summary for possibly easier scanning.
Comment #38
MustangGB CreditAttribution: MustangGB commented@Gábor Hojtsy
Could you/someone and @kiamlaluno have a discussion please?
He goes through and removes "in Drupal 7" from a load of issues, you and other go and add them back in.
Personally I don't see the point of it, the version filter is there for a reason, but either way can we come to a consensus on this?
Comment #39
Gábor HojtsyThe version filter is indeed useful on drupal.org. However consider when the issue is shared on Slack, social media (eg. https://twitter.com/gaborhojtsy/status/1224614436566114304) or even linking from issue comments, such as #3081386: [META] Fully support PHP 7.4 in Drupal 7 or in the sidebar related issues list. There is no indication of the Drupal major version it relates to in those cases.
In cases like this where the issue applies to all currently supported major versions of Drupal and they have different drupal.org issues to fix the problem, I strongly believe including it in the title is important. That said, I'll not go after @kiamlaluno to fix whatever he was updating :)
Comment #40
izmeez CreditAttribution: izmeez commented1+ for added clarity by including "... in Drupal 7"
Comment #41
pratik_kambleComment #42
pratik_kambleComment #43
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commentedAnyone here know how we go about getting some of the patches in the child tickets committed? Do they need more review or attention from a core committer (If so how do we get such attention?)
Comment #44
Gábor Hojtsy@Steven Jones it depends, there is definitely a bunch of issues that still need review (in the issue summary the ones that are not green). I count five of them. The ones that are green would need a Drupal 7 committer review. That said, verifying you agree it works and is a good solution would help to make it more likely to be committed faster.
Comment #45
MustangGB CreditAttribution: MustangGB commentedWe got a new core maintainer a few months back, but it's all gone quiet again.
Comment #46
joseph.olstadFork
Comment #47
Ayesh CreditAttribution: Ayesh commentedI met Drew (new D7 maintainer) at FOSDEM, and he mentioned he's currently busy with some exams and will attend the issues after.
Comment #48
anavarreLet's all remember there's https://www.drupal.org/core/drupal7-roadmap-release-schedule#release-sch... which clearly outlines the release schedule for Drupal 7 going forward. The next release is scheduled for 2020-06-03 and I'm sure core committers will ensure D7 is compatible with PHP 7.4 then.
Comment #49
mcdruidThank you for all the work that's gone into this so far. It's definitely the goal to get this into the next release (due 2020-06-03).
This is a no-op patch which we can use to test 7.x-dev with PHP 7.4 - we can then compare the test run with those for patches in individual issues to verify whether the patch fixes particular test failures.
Comment #50
mcdruidI'm still trying to work out whether this is a good methodology when the test results are initially so noisy, but here's one way of seeing the exceptions from the failing PHP 7.4 test for the no-op patch in #49:
(Please try not to hammer the drupal.org CI infra with excessive requests etc..)
That list seems fairly useful e.g. to compare with the test results for individual patches to confirm that they resolve individual items on the list e.g.:
I'm also looking at the list to give us a hint for prioritisation; starting at the top seems like it makes some sense.
Hopefully we'll see the list get shorter as start committing the fixes.
Comment #51
mcdruidComment #52
mcdruidWe've just committed 4 patches which should resolve several of the Notices / fails in the PHP 7.4 tests.
There's certainly still more to do though.
Here's another very similar no-op patch; with any luck the PHP 7.4 test for this should look a little better (and can be used to compare patches in the sub issues as we continue to work on them).
Comment #53
mcdruidErm.. :) I'll chase this up on Monday with the d.o infra team.
Comment #54
joseph.olstadKeep up the great work!
Note, there's a problem with the test runner, but this shouldn't slow you down from the progress here. If you need, I could set up an test environment for you with simpletest and shell access?
I've noted in this issue:
#2997871: D7 testing broken
Comment #55
MustangGB CreditAttribution: MustangGB commentedComment #56
mcdruidThanks for the offer @joseph.olstad - looks like it was a short-lived blip though.
Looks like we've gone from 2,031 pass, 886 fail in #49 to 2,049 pass, 119 fail in #52.
Progress.
Comment #57
joseph.olstadMuch better, only 119 to go! :)
Comment #58
mcdruidComment #59
Taran2L@mcdruid I really like how you approach this! Great job!
Comment #60
mcdruidWe ended up reverting #3084935: element_children() and DrupalRequestSanitizer::stripDangerousValues() should not use integer keys as array because it broke PHP < 5.6 but a new fix has just been committed there which should keep everything from PHP 5.3 to 7.4 happy (although we're not done with the 7.4 fixes yet).
Here's another no-op patch to confirm what condition our condition is in.
Comment #61
joseph.olstadNice work, looks like only 1 fail out of 2050, according to the test results 2051 passes on all the earlier versions and 2050 passes on 7.4.x. For kicks I triggered 5.4 and 5.5
Comment #62
mcdruidIt's good that we're making progress.
A bit strange that there are a few test fails on PHP 5.4 but I don't think we need be concerned; we discussed this in #3092260: [policy, no patch] Review and update automated testing config for 7.x branch and I don't think 5.4 is a version we need to test on.
If anyone disagrees with that, let's please discuss in that other meta issue on testing rather than here. Thanks!
Comment #63
Liam MorlandOne PHP 5.4 fails and the other passes, but they appear to be the same. Why do they both appear?
Comment #64
apaderno@Liam Because the patch have been re-tested for PHP 5.4. (See comment #61.)
Comment #65
Liam MorlandNormally the more recent tests overwrite the older test on the same PHP and DB versions.
Comment #66
apadernoI guess it depends from how the environment test has been selected. Since the tests were run for PHP 5.4 and 5.5, it could be Retest […] was not used in this case.
Comment #67
Liam MorlandYes, these must have been "Custom parameters" tests which don't replace older ones.
Comment #68
Taran2L@kiamlaluno @Liam Morland I've pressed the button; and yes, a retest button was not available, so I've used custom parameters option which (it seems) does not replace the previous run; however it's the same environment, see https://www.drupal.org/pift-ci-job/1617927 and https://www.drupal.org/pift-ci-job/1618682 both lead to the same page
Comment #69
mcdruidHere are the counts of exceptions from the PHP 7.4 test in #60:
Working from the top of that list, I think the next 5 issues to tackle would be:
Comment #70
mcdruidJust committed those 5 patches from #69
Here's another no-op patch to see what we still have left to do for PHP 7.4 in D7.
Comment #71
mcdruidUpdating the IS.
Comment #72
mcdruidThe list is getting shorter:
Comment #73
Ayesh CreditAttribution: Ayesh commented👍🏽 awesome, thank you. #3118301: Curly brace syntax for accessing array elements and string offsets has been deprecated in PHP 7.4 looks quite straight forward too.
Comment #74
joseph.olstad@mcdruid, excellent work, I am asking you or @Fabianx to please add an automated test on commit for php 7.4 on the Drupal 7 dev branch here: https://www.drupal.org/node/3060/qa
This will help us indicate how many tests are succeeding. ** Edit, I just noticed the patch to this issue for tests, only 20 left to go, still would be a good idea to have the test enabled **
Comment #75
mcdruid@joseph.olstad the plan is to enable automatic testing on PHP 7.4 when we're happy that the 7.x branch should pass.
Looking at the remaining exceptions from the last round of tests, I think these are the next issues to tackle (one is a new one I've filed for the forum module - if there's already an issue for this, we'll close one as a dupe - I'll add this to the IS):
That's not yet all of the outstanding children of this issue; it'd be interesting to see what tests look like with these 4 resolved, as they look like they account for most if not all of the remaining exceptions/notices.
Comment #76
Taran2LActually, there are more small issues. Originally there was a patch (see #22) fixing those smaller items. I completely forgot to put them into separate issues (some of them now have separate issues):
number_float=>number_decimal(line 178 of modules/field/modules/number/number.test)select=>options_select(line 452 of modules/taxonomy/taxonomy.install)simpletest_script_print(), which is not triggered by any test (line 733 of scripts/run-tests.sh)UPDATE:
Added 3 new issues addressing items 3-5 from the list above:
Comment #77
Taran2LComment #78
joseph.olstadadded #3126312: Since PHP 7 func_get_args() no longer reports the original value as passed to a parameter, so call it early
Comment #79
joseph.olstadadded #2788565: sample code for callback_filter_process() and callback_filter_prepare() should not include deprecated regex option
Comment #80
mcdruidThanks for adding all of those.
I've been working on #3085163: Comment module causes PHP 7.4 Notices on uninstall which ended up being a bit of a rabbit hole.
In the process, I've started to address a small handful of the several exceptions from field.crud.inc and image.module - these mostly look pretty similar and are a result of e.g.
$field's being passed around by hooks etc.. where$fieldis either not an array at all or doesn't include expected elements such as$field['type'].In a quick review of the remaining child issues we have in this issue, I've not found patches which address the exceptions in field.crud.inc and image.module so I'm going to file a new issue which lists all of them and work on a patch.
Couple of thoughts though:
I think that last question is probably one we should discuss in the new issue rather than here.
Comment #81
mcdruidCreated #3129961: Fix $field / $instance exceptions in field.crud.inc and image.module
Comment #82
Taran2Lhi @mcdruid
There are at least 3 other issues related to the Field API:
#3126133: NumberFieldTestCase uses non-existing formatter number_float
#3126138: taxonomy_update_7004() uses non-existent widget select
#3085148: Fix field_test_field_attach_delete_bundle()
Comment #83
mcdruidUpdated IS; 8 more issues moved to Done.
Comment #84
mcdruidAnother no-op patch to see what condition our condition is in, tests wise.
Comment #85
joseph.olstad@Taran2L , should those items be added to the issue summary ? see comment #3081386-82: [META] Fully support PHP 7.4 in Drupal 7
Comment #86
Liam Morland@#85: The issues mentioned in #82 are in the summary.
Comment #87
joseph.olstadoh wow! only 3 to go, nice!
curiously, it still says 2053 passes on both 7.2 and 7.4 test results, interesting!
Comment #88
Ayesh CreditAttribution: Ayesh commented--nevermind--
Sorry.
Comment #89
Liam MorlandComment #90
mcdruidWe just committed the last 4 on the list in the IS (which I've updated).
With any luck, Drupal 7 now passes tests with PHP 7.4 - (last?) noop patch to verify that.
Comment #91
mcdruidThere are other PHP 7 issues still in the queue in varying states of readiness.
I think we can call this one fixed now though, as tests pass and we've got all the way through the list.
Thanks everyone for all the hard work that's gone into making Drupal 7 compatible with PHP 7.4!
Comment #92
joseph.olstadwow, 100% passing, this is great!
Comment #93
Ayesh CreditAttribution: Ayesh commented🎉🎉🎉🍾 This is great! Thanks to those who submitted issues/patches/feedback and Drew for triaging and applying them to core.
Comment #94
mcdruidI've switched on automated testing for
PHP 7.4 / MySQL 5.5on D7 core.Comment #95
joseph.olstadso how much more stuff are you going to jam into 7.71 ? There's lots of RTBC to choose from.
Comment #96
ronlee CreditAttribution: ronlee commentedAny timeline when this will be pushed to production?
Comment #97
mcdruidhttps://www.drupal.org/core/drupal7-roadmap-release-schedule#release-sch...
Comment #98
ronlee CreditAttribution: ronlee commented@mcdruid Thank you.
Comment #99
elioshSo, with enormous thanks to all contributors, we can expect the new release on 2020-06-03 with all those patches?
It would be great!!!!
:-)
Comment #100
joseph.olstad@eliosh if you want to help out, send contact messages to all contrib module maintainers
now is the time to push contrib maintainers to add php 7.4 automated tests on commit for each project, so that we can test contrib , modules like views for instance currently only testing up to php 7.3.x.
Comment #102
ronlee CreditAttribution: ronlee commentedNow that we have php7.4 support, any ideas which files to add to opcache preload?
I'm not finding any information online about this. :(
Comment #103
Ayesh CreditAttribution: Ayesh commentedOpcache preloading is better to be outside the scope of this ticket, or let alone Drupal because it's something not easily done in a way that suits everyone.
I maintain Composer Preload (https://github.com/Ayesh/Composer-Preload) that has support for all projects. Your Drupal site doesn't even have to meaningfully use Composer.
Generally speaking, all `.php`, `.inc`, and `.module` files in `./includes`, `./modules`, `./sites/all/modules`, and your theme directory are better preloaded.
Comment #104
cilefen CreditAttribution: cilefen commented#3151810: D7.71: Array and string offset access with curly braces is deprecated in PHP 7.4
Comment #105
mfbAnother PHP 7.4 issue at #3155357: menu tree output() notice after upgrade to php 7.4 with core 7.72
Comment #106
joseph.olstad@Taran2L
wondering if you can do for PHP 8 , what you did for PHP 7.4 ?
PHP 8 support:
#3145797: [META] Make Drupal 7 core compatible with PHP 8.0
Comment #107
Taran2L@joseph.olstad, as far as I can see there is not that much work :)
anyway, seems like the drupal.org test bot cannot run PHP8 + D7, right?
Comment #108
heddnNo, it is possible to run php 8 testing
Comment #109
Ayesh CreditAttribution: Ayesh commentedAlso, I wouldn't really call Drupal 7 on PHP 8 as "there is not that much work".
I could not get Drupal 7 to run in PHP 8 at all, until #3185918: [PP-1] [PHP 8] Fix DatabaseConnection::query signature mismatch with PDO::query is fixed. Unfortunately, I am afraid more major issues are yet to be discovered in the first place. It would be a massive feat to have Drupal 7 working with PHP 5.3, 7.x, and 8.0 working, and with D7's EOL extended by two years, I think it will be a lot of work.
Comment #110
joseph.olstadDrupal 7 will run on PHP 8. Taran2L will work his magic again, and if not him, someone else will come through for us.
Comment #111
Gábor Hojtsy@joseph.olstad: the matter of fact is @Ayesh has been working on #3145797: [META] Make Drupal 7 core compatible with PHP 8.0 for half a year (alongside Liam Morland). Would be great to continue the PHP 8 discussion there.