Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Make sure Drupal 7 becomes and remains compatible with PHP 8.0. Work with dependencies as needed. See #3081386: [META] Fully support PHP 7.4 in Drupal 7 for how we did it with PHP 7.4.
While an initial set of issues landed, there are still some issues remaining:
Issue fork drupal-3145797
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mcdruidThanks for filing this :)
Comment #3
Ayesh CreditAttribution: Ayesh commentedRunning PHP 8 tests...
Comment #4
rgpublicWhats going on here - I see an immediate Composer error on the tests? Anything that needs to be done about it?
Comment #5
Liam MorlandThis noop patch should always apply.
Comment #6
andypostIn needs to override CI command to by-pass composer
Comment #7
rgpublic@andypost: So, what do we do now about this? Do we have to contact/inform anyone who can change/fix this?
Comment #8
sjerdoThe --ignore-platform-reqs option should'nt be used for D7 since testbot CI doesn't use composer to install D7.
However, The PHP 8.0 & MySQL 5.7 errors should be fixed: D7 bootstrap fails due to multiple errors:
Comment #9
fgmGot a deprecation warning related to PHP 8 on D7, which doesn't appear here:- Deprecated function: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in include_once() (line 1387 of (...)/includes/bootstrap.inc).Not sure whether it should go here or in another issue ?Child issue is #3156847: [PHP 8] Parameter order fixes.Comment #10
andypost@fgm ++ to create child issue
Comment #11
mcdruidYes please; child issues for each separate problem.
Comment #12
Ayesh CreditAttribution: Ayesh commentedI managed to get Drupal (current branch HEAD) working with PHP 8. There were couple changes needed in filter.module to to disable its error reporter for HTML 5 compatibility, and
_drupal_error_handler
update necessary to avoid ArgumentCountError exceptions, which I'm not sure are PHP 8.0 exclusive (as it could be a libxml change too).I'm loading a patch of my copy if anyone would like to replicate it. None of patches are reviewed by community, so please don't use on any site worth its salt.
Comment #13
Ayesh CreditAttribution: Ayesh commentedComment #14
Ayesh CreditAttribution: Ayesh commentedComment #15
andypostit looks ok
why that change?
it probably needs some workaround if query() method affected
all this fixes could go to paramemters issue
this line needs comment explaining why and probably call it for php>=800
Comment #16
Gábor HojtsyUpdating issue title and summary since PHP 8 is out, so it does not evolve anymore.
Comment #17
Taran2LSo, I've spent a decent amount of time looking at this, and seems like the effort required to have D7 running on PHP8 is comparable to D7 on the PHP7.4 issue.
However, here there is a single more challenging piece: database API, which inherits from PDO directly.
I will be creating some children issues in a few following days, so stay tuned :)
Comment #18
Gábor Hojtsy@Taran2L: did you find more on top of #3185918: [PP-1] [PHP 8] Fix DatabaseConnection::query signature mismatch with PDO::query?
Comment #19
Taran2L@Gábor Hojtsy, yes. Please check the corresponding issue.
Comment #21
Taran2LSo, as promised I spent some time on this:
There are 5 issues that prevent test runs 2 of them are more or less straightforward; 3 are more complex/problematic. After fixing those 5, the rest should be more or less easy (see the 17 fails above)
Easier ones:
More complex issues are all database connection management related:
__destruct()
but thekernel.terminate
eventPoC for the 5 issues above is in the 361 MR
Comment #22
mcdruidThanks for all the work that's gone into this so far.
I've been looking at:
...and running the Database tests locally with PHP 8.0 with all of those changes.
Seems like we're very close to passing, but I've hit this exception which I wanted to record for posterity:
That seems to be roughly between
DatabaseTransactionTestCase->testCommittedTransaction()
andDatabaseTransactionTestCase->testTransactionStacking()
but I'm not certain which test actually triggered this.Comment #23
mcdruidThe DB test fail mentioned in #22 looks like it's caused by a change in PHP 8.0 which has already been addressed in D8/9.
Here's a backport issue to fix that in D7: #3204161: [D7] MySQL on PHP 8 now errors when committing or rolling back when there is no active transaction
Comment #24
Taran2Lhi @mcdruid, there is another issue that needs to be committed before going into PDO issues #3156847: [PHP 8] Parameter order fixes
Comment #25
mcdruidThanks @Taran2L - there are now 5x PHP 8.0 issues at the top of #3192080: [meta] Priorities for 2021-04-07 release of Drupal 7 and that includes the param order one you mention.
I plan to focus on those in order to make it practical to start testing PHP 8.0 with drupalci.
Do you know of any other blockers for testing?
Comment #26
mcdruidWe've now got tests running through properly.
AFAICS there are 5 tests with failures:
Some of those may be covered by existing issues, but I've created one new issue per test:
(combined two test failure lines from above, both relate to SimpleTest)
Comment #27
mcdruidplus #3206438: [PHP 8] deprecated functions in OpenID
Comment #28
mcdruidWow - thanks for jumping on these last few issues!
I'd half forgotten the approach that seemed to work quite well for PHP 7.4 (#3081386-50: [META] Fully support PHP 7.4 in Drupal 7).
Let's try that with the last test of @Liam Morland's noop's patch in #5:
Any of those not covered by the issues we're already working on?
Will try to get these all reviewed and committed ASAP.
Comment #29
joseph.olstadlooking forward to this, as soon as those get committed I'll start updating all my contrib projects to enable php 8 testing
Comment #30
Taran2LLet's test all patches combined in this noop issue.
Comment #31
Taran2LComment #32
joseph.olstadWOW! Great work @Taran2L and @mcdruid!
Congrats!
Comment #33
mcdruidSo that's a combination of the patches from the 4 issues listed in #28 @Taran2L?
Comment #34
Taran2Lhi @mcdruid, yes, exactly
Comment #35
Liam MorlandComment #36
Ayesh CreditAttribution: Ayesh commentedWoot woot! Tests passing, thanks for the amazing work everyone 🚀.
Comment #37
mcdruidCommitted all of those changes this morning; we now have tests passing in PHP 8(.0)!
Thanks to all the contributors - I wasn't sure we'd get this far in time for the release next week, but am pleasantly surprised.
I won't close this issue yet as there may well be more PHP 8 fixes not revealed by the test suite.
We won't leave it open indefinitely though.
Comment #38
joseph.olstadTriggered php 8 tests for 'media'
https://www.drupal.org/pift-ci-job/2019363
Triggered php 8 tests for 'file_entity'
https://www.drupal.org/pift-ci-job/2019361
I will add tests for other projects probably this weekend.
Thanks again everyone!
Comment #39
Taran2L@mcdruid, thanks for your time and fast processing times! Great job.
Thanks to everyone else involved!
Comment #40
joseph.olstadCore is ready, there'll be lots of work in contrib
assistance with media and file_entity is appreciated
Comment #41
robertwb CreditAttribution: robertwb commentedI would like to test PHP 8.0 & Postgresql.x. My local install showed an error, but I would prefer the automated test bot so that I can insure that it is not something peculiar about my install (it was an Ubuntu server upgraded from 18.04 to 20.04 and there were some hiccups reported by the sysadmin during upgrade).
Comment #42
Tino CreditAttribution: Tino commentedNot sure if this is the place to report this, but when I upgrade my shared server from PHP 7.4 to 8.0, Drupal 7.81 cannot add nodes anymore. When saving them an unexpected error notification is displayed. Just viewing the websites does not cause any issues.
Comment #43
joseph.olstad@Tino, please keep in mind that there's still several contrib modules that will need some changes /patching /updating to get PHP 8.0 working correctly. Thanks for reporting, if you have access to logs, please report where appropriate, open new issues if you need for various projects and share the links.
Comment #44
Tino CreditAttribution: Tino commented@joseph.olstad Got it, thanks! It's the Rules module (7.x-2.12).
Type: PHP
Error: Unknown named parameter $settings in FacesExtendable->__call() line 125 of /sites/all/modules/rules/includes/faces.inc).
Comment #45
joseph.olstad@Tino, there is a work in progress issue for the rules module.
#3209769-8: [meta] Make D7 rules compatible with PHP 8.0/8.1
Comment #46
Tino CreditAttribution: Tino commentedAwesome! Thank you @joseph.olstad.
The latest developement version of Rules (7.x-2.x-dev updated 10 Jun 2021 at 22:25 UTC) works with PHP 8.0.
Comment #47
joseph.olstadphp 8.0 tests for entity api:
the entity api module test has rules as a dependency, throws this error:
Unknown named parameter $type in FacesExtendable->__call() line 125 of rules/includes/faces.inc
not sure where to fix this yet. should the fix go into 'rules/includes/faces.inc' ?
when I googled I came accross this issue for core
here's the link to the entity api automated test run :
Comment #48
joseph.olstadThe entity api issue might be because the tests dependency picking up the latest tagged release of rules which doesn't have the fix instead of the dev release that does have the php 8.0 fix.
We should ask the rules maintainer to tag a php 8.0 compatible release from the php 8.0 compatible dev branch of rules
?
Comment #49
Liam MorlandThat ought to have been fixed in #3210622: [D7] PHP 8.0 introduced breaking change to call_user_func_array(). That commit is not yet in a release.
Comment #50
joseph.olstad@mcdruid,
I guess we can mark this issue as fixed once we confirm the entity api is fixed by tagging, releasing the latest rules build ? @TR will probably do that for us soon.
Comment #51
joseph.olstadthere's a chain of events that have to happen for us to resolve file_entity and media module php 8.0 automated test passing as media relies on file_entity, which in turn automated tests depend on the entity api which in turn relies on rules for it's automated test coverage dependency.
so , in this order:
Comment #52
MustangGB CreditAttribution: MustangGB commentedColour me confused, but what do all these different contrib modules have to do with core?
Should they not be discussed in their own issue queue?
Comment #53
joseph.olstad@MustangGB , nothing other than they use core.
this issue can probably be closed as "Fixed"
Comment #54
Gábor HojtsySince #37, there were only reports of contributed projects not being compatible. Let's close this one! I think it is worth tracking PHP 8 issues for Drupal 7 contributed projects (and tagging them with "PHP 8.0" especially) but this issue was for core.
Comment #55
MustangGB CreditAttribution: MustangGB commentedHow is this fixed when there are still open child issues?
Comment #56
Gábor Hojtsy@MustanGB: good point, unfortunately those were not reflected in the comments or issue summary that I've seen.
I looked at the child issues and retitled #3224299: [META] Make Drupal 7 core compatible with PHP 8.1 and made it related instead of a child. Fixing that is not required to make PHP 8.0 compatibility :)
Looks like the other three open children are core issues.
#3165377: element_property() causes a notice in 7.4 if $key is integer
#3179120: Address operator priority change in PHP 8
#3210215: [PHP 8] Error: TypeError: round() in parse_size function
Added them to the issue summary as well.
Comment #57
joseph.olstadNow with 3165377 fixed, I retriggered media automated tests today with php 8.0 and it's all GREEN. I'm now triggering file_entity and I suspect it will also be all green but not sure yet.
#3165377: element_property() causes a notice in 7.4 if $key is integer
Comment #58
joseph.olstad*** EDITTED ***
another update, two more GREEN php 8.0 compatible contrib modules
media is now passing PHP 8.0 tests
and thanks again to @mcdruid, he helped pinpoint a fix for file_entity also and a new release of file_entity fixes php 8.0 compatibility
#3208277: PHP 8 compatibility for file_entity
Comment #59
mcdruidThe 3x child issues mentioned in #56 (and earlier comments) are now fixed or postponed (pretty sure that one is not a problem in core).
So I'm going to close this as fixed, and we'll move on to PHP 8.1 :) Thanks everybody that contributed here.
Comment #60
MustangGB CreditAttribution: MustangGB commentedGreat stuff, and thanks to both of you (Drew and Gabor) for listening.