Problem/Motivation
Make sure Drupal 9 keeps being compatible with PHP 8.1. Work with dependencies as needed. See #3109885: [meta] Ensure compatibility of Drupal 9 with PHP 8.0 (as it evolves) for how we did it with PHP 8.0. PHP 8.1-alpha1 is now released, see https://www.php.net/archive/2021.php#2021-06-10-1
Proposed resolution
Figure out what breaks. Itemize and resolve one by one.
1. Dependency updates to support PHP 8
List of upstream updates in progress
List of upstream dependencies that are likely to lack PHP 8.1 support
- Guzzle 6 https://github.com/guzzle/guzzle/pull/2918 - they want us to move to 7. Can use namespace hacking to fix this - see #41 and #3224421: [PHP 8.1] Add a shim to Guzzle 6 for PHP 8.1 compatibility
Upstream fixes that are merged but need a release: NONE
Released but waiting composer update: NONE
DONE
- vfsStream - https://github.com/bovigo/vfsStream/issues/263
- Laminas Feed - #3238201: Update dependencies for 9.3.x
- twig/twig https://github.com/twigphp/Twig/pull/3536 and https://github.com/twigphp/Twig/pull/3552
- Prophecy - https://github.com/phpspec/prophecy/pull/533 / https://github.com/phpspec/prophecy/issues/531
- justinrainbow/json-schema https://github.com/justinrainbow/json-schema/pull/657
- symfony/yaml https://github.com/symfony/symfony/pull/42074
- symfony/http-foundation new info in $_FILES - https://github.com/symfony/symfony/pull/42112
- More Symfony return type fixes https://github.com/symfony/symfony/pull/42260
- PHP https://bugs.php.net/bug.php?id=81273 (found in \Drupal\Tests\Component\Datetime\DateTimePlusTest)
- Doctrine reflection - it is abandoned and now we no longer use it in core - #3180351: doctrine/reflection is abandoned
- behat/mink-selenium2-driver https://github.com/minkphp/MinkSelenium2Driver/issues/338
- behat/mink https://github.com/minkphp/Mink/issues/811
- PHPCS https://github.com/squizlabs/PHP_CodeSniffer/pull/3394 (does not cause errors in tests but is very noisy in CLI - new release is out https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.6.1
2. Internal Drupal issues
Complete. See related issues side bar :)
Release notes snippet
Drupal 9.3.x is tested on PHP 8.1.
Comment | File | Size | Author |
---|
Issue fork drupal-3220021
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
Gábor HojtsyComment #3
Gábor HojtsyFix backlink to PHP 8 issue.
Comment #4
andypostFailures with reflection could use to extend core's wrapper created in #3156542: \ReflectionParameter::getClass() is deprecated in PHP 8.0
Comment #5
Gábor HojtsyPer @Mixologic earlier results are available at https://dispatcher.drupalci.org/job/drupal8_core_regression_tests/40398/... (while this one is still in the queue).
Comment #6
andypostcomposer deprecation notice should be fixed in https://github.com/justinrainbow/json-schema/pull/666 and then propagated to composer, filed https://github.com/composer/composer/issues/9981
EDIT composer compatibility issue https://github.com/composer/composer/issues/9718 and another fix is https://github.com/justinrainbow/json-schema/pull/657
Comment #7
andypostPHP Deprecated: Declaration of Drupal\Core\Template\Attribute::jsonSerialize() should be compatible with JsonSerializable::jsonSerialize(): mixed in /var/www/html/core/lib/Drupal/Core/Template/Attribute.php on line 372
could wait when core will require PHP 8 to add "mixed" to result of\Drupal\Core\Template\Attribute::jsonSerialize()
Ref https://www.php.net/manual/en/language.types.declarations.php#language.t...
Comment #8
andypostLots of
Deprecated: Declaration of Doctrine\Common\Reflection\StaticReflectionClass::getName() should be compatible with ReflectionClass::getName(): string in /var/www/html/vendor/doctrine/reflection/lib/Doctrine/Common/Reflection/StaticReflectionClass.php on line 28
require to file issues to doctrineComment #9
alexpottHere's a start that allows some unit and kernel tests to run without error.
Symfony's session stuff is going to be fun and the Doctrine reflection stuff will be fun again - especially now that it is deprecated.
Comment #11
longwaveThis is another reason to move forward with #3180351: doctrine/reflection is abandoned
Comment #12
longwaveTrying this locally via early support in ddev (https://github.com/drud/ddev-contrib/pull/141), the patch helps but then I am seeing a strange error with the autoloader after logging in - there is no reason I can see that this class can't be found:
Maybe I should just wait for a more stable release.
edit: turns out this was likely user error in my container setup and not a PHP or Drupal problem
Comment #13
andypostAlpha 2 coming tomorrow
Comment #14
andypostThere's https://github.com/spiral/attributes a piolifill to use native attributes
Comment #15
longwavebehat/mink and masterminds/html5 both trigger PHP deprecations, so upstream will need fixes for those, or we need to work around them. We also need to catch PHP deprecations the same way we catch and pass on userland deprecations in TestHttpClientMiddleware otherwise any functional test that triggers a deprecation in the test site results in a hard fail.
I've skipped a number of PHP deprecations for the time being until we track down the source of each and fix them. Locally this gets some functional tests running, and even a few passing.
Comment #16
longwaveI'm sure this will be fun to debug!
Comment #17
MixologicThere's actually some tools built into drupalci to help with segfaults.
We build the php containers with the debug symbols, and whenever a segfault is detected, a GDB script runs and produces a backtrace of *where* in php the segfault occurred. Usually this is helpful for pushing things back upstream to PHP (we found so many with our testsuite that they delayed php7 by a couple of months to fix them all)
I would try submitting a patch with just that one test to see if you can cause it to segfault on the testbots, and there should be some data in the artifacts directory with details as to what caused the segfault.
Comment #18
alexpottI think we need to actually fix these. At least we have in the past.
Comment #19
longwaveWe totally do, I was just trying to get closer to a green run first without those getting in the way, then hopefully we can pick these off one by one as we do with other deprecations.
Comment #20
longwaveAdded all the deprecations from the last run.
Comment #21
longwaveComment #22
longwaveThe bulk of this looks like this is going to be quite a laborious task of adding checks or casts around values passed to numerous PHP builtin functions :(
Additionally, any tests that use
mikey179/vfsstream
are failing with a deprecation warning due to https://github.com/bovigo/vfsStream/issues/252 - but upgrading that to 1.x-dev brings with it its own deprecation:Finally, some uses of Prophecy also seems to be generating some deprecation warnings which then turn into a crash, e.g.
$this->prophesize(MarkupInterface::class)
:Comment #23
longwaveUpgrading Twig for https://github.com/twigphp/Twig/issues/3534 helps a lot.
Comment #25
andypostAnother option is setting for phpunit https://github.com/twigphp/Twig/issues/3534#issuecomment-859866066
Comment #26
longwaveWith Symfony 4.4.26 we can drop the HttpFoundation workarounds: https://github.com/symfony/symfony/pull/41495
I guess we might need to sprinkle our own code with
#[ReturnTypeWillChange]
to start with.Comment #27
alexpottNote this is an xpost with #26...
@longwave I'm not sure the best to get green is to skip all the errors. That's not how we've done it before. On the other issues like this we've worked through each error till we get each test green.
Upgrading symfony/http-foundation and masterminds/html5 fixes quite a bit too. We should do the same as Twig and Symfony and us the PHP annotation to indicate the return type will change - i.e.
#[\ReturnTypeWillChange]
.The patch attached has a green
\Drupal\Tests\system\Functional\Module\InstallUninstallTest
Opened https://github.com/symfony/symfony/pull/42074 for one deprecation.
We need to open a PR against Mink too.
Comment #28
longwave@alexpott because there are so many deprecations my intent was to get it green with skips (or at least some numbers reported back!) and then try to fix them one by one in spinoff issues, a bit like we have with PHPUnit deprecations - otherwise I feel this patch is going to become enormous very quickly
Comment #30
alexpottI think we need to ask for the PHP 8.1 fix for bovigo\vfs to be backported to the version we're on - or at least more compatible with it...
... that's going to break a lot of contrib.
Comment #31
alexpott@longwave I think it is fine for this patch to get enormous - it's a scope of work and not much of it is worth carving into separate issues really. I'm not convinced that lots of little issues for each string cast or ?? '' in a string function is helpful. Things like the syslog config on install fix - that definitely should be it's own issue.
Comment #32
longwaveThe bovigo\vfs issues are a bad find/replace on my part, pushed another set of fixes for this that should now be complete - worth spinning this off to its own issue and getting it committed?
Comment #33
alexpott@longwave we need a bovigo\vfs release before we should do that. What would be good is to update our 9.3.x dependencies now... because that'd get us a couple of fixes.
Comment #34
longwaveOh yeah, 1.6.7 doesn't include the new namespaces. https://github.com/bovigo/vfsStream/issues/252#issuecomment-836191861 notes there will be a new 1.6.x or 1.7.x later this year.
Comment #35
longwaveSome of the exception changes overlap with #3209619: [Symfony 6] Passing null as $message to Symfony exception constructors is deprecated, pass an empty string instead but I think there might be subtle BC breaks:
What if someone throws CacheableAccessDeniedHttpException with no message, and later catches it and checks $message === NULL?
Comment #36
alexpottRe #35 I think think we're going to have that kind of problem. Imo checking for a message === NULL is just not supported. Use empty(). It's great that #3209619: [Symfony 6] Passing null as $message to Symfony exception constructors is deprecated, pass an empty string instead exists to discuss this already. The NULL exception message is one obvious issue to break out.
Comment #37
alexpottAdding some info about dependency updates - more to be added.
Comment #38
alexpottAdding more upstream issues.
Comment #39
alexpottThe remaining fails are:
Now it's time to create some Drupal issues for the runtime fixes here.
Comment #40
alexpottComment #41
longwaveTo sidestep the Guzzle issue, we can use a shim. Guzzle doesn't use
use function
or prefix its function calls with\
- so we can overridehttp_build_query()
in the GuzzleHttp namespace, and intercept and rewrite the calls as necessary. Something like:Comment #42
alexpottComment #43
alexpottComment #44
longwaveComment #45
alexpottComment #46
andypostLooking at https://github.com/php/php-src/blob/php-8.1.0beta1/UPGRADING#L486-L489
there's current core usage
I bet it needs separate issue as mostly tests are affected
Comment #47
longwave@andypost we can't change that until we require minimum PHP 8.1 though?
Comment #48
alexpottComment #49
alexpottComment #50
andypostAdditionally pecl yaml extension fails to build with PHP 8.1 so d-org infra can't upgrade to beta
Filed pr to fix that https://github.com/php/pecl-file_formats-yaml/pull/60
Comment #51
andypostAdded #3212021: [PHP 8.1] Serializable interface is deprecated to child tasks
Comment #52
alexpottComment #53
alexpottComment #54
alexpottComment #55
alexpottComment #56
daffie CreditAttribution: daffie commentedComment #57
andypostSF issue about
Countable
https://github.com/symfony/symfony/pull/42260Comment #58
alexpottComment #59
daffie CreditAttribution: daffie commented#3224592: \Drupal\path_alias\AliasManager::cacheClear() can cause deprecations on PHP 8.1 and when set to NULL it tries to flush the cache but that's not possible has landed.
Comment #60
alexpottProphecy has a PR for 8.1 compatibility - https://github.com/phpspec/prophecy/pull/533 - I've applied it as a patch via our composer phpunit update commands for now and it is working.
Comment #61
andypostBetter linking
Comment #62
andypostBeta 2 announced https://www.php.net/archive/2021.php#2021-08-05-2
Comment #63
daffie CreditAttribution: daffie commentedBoth #3180351: doctrine/reflection is abandoned and #3224414: Installing the syslog module uses its configuration before it is written have landed.
Comment #64
alexpottComment #65
alexpottComment #66
alexpottUpdating issue summary with the info about what would prevent an install on PHP 8.1 due to PHP requirements. Note that these upper constraints don't affect drupal core dev because set the platform in the root composer json but it will affect anything built from core recommended and the other project templates.
Comment #67
alexpottComment #68
andypostSF tracking changes in https://github.com/symfony/symfony/issues/41552
Comment #69
andypostFiled #3230562: Update dependencies for Drupal 9.3 as a lots of updates arrived
Comment #70
alexpottMerged in the Symfony updates fwiw.
Comment #71
alexpottUpdating list of Drupal issues.
Comment #72
Gábor HojtsyPHP 8.1.0 RC1 is now announced! https://www.php.net/archive/2021.php#2021-09-02-1
Comment #73
catchComment #74
andypostProphecy got a new release
https://github.com/phpspec/prophecy/releases/tag/1.14.0
Comment #75
alexpottCreated #3232571: Update dependencies for 9.3.x to address #74
Comment #76
alexpottComment #77
daffie CreditAttribution: daffie commentedComment #78
daffie CreditAttribution: daffie commentedComment #79
alexpottMerged 9.3.x - there's been some progress. For our dependencies:
Comment #80
daffie CreditAttribution: daffie commented#3232571: Update dependencies for 9.3.x has landed and with that the 2 problems with Prophecy have been fixed.
Comment #81
daffie CreditAttribution: daffie commentedThe 2 twig fixes have had a release and landed in the vendor directory.
Comment #82
alexpottMaking the why-not command correct.
Comment #83
daffie CreditAttribution: daffie commentedPHP 8.1 RC2 is out. See: https://www.php.net/archive/2021.php#2021-09-16-1
Could we get a testbot run with 8.1 RC2?
Comment #84
andypost@daffie it's already rc2 - https://www.drupal.org/pift-ci-job/2181317
Comment #85
alexpottComment #86
alexpottI've updated the issue summary to point to the github issues asking for a PHP 8.1 compatible stable release for behat/mink, behat/mink-selenium2-driver and mikey179/vfsstream .
Comment #87
daffie CreditAttribution: daffie commented#3212021: [PHP 8.1] Serializable interface is deprecated has landed.
Comment #88
daffie CreditAttribution: daffie commentedChild issue to be fixed:
Comment #89
alexpott@daffie thanks for updating the issue summary. 3224941 doesn't need fixing yet - it's open for when core's minimum PHP version is PHP 8.1 - feels quite a way off :)
Comment #90
daffie CreditAttribution: daffie commented#3224421: [PHP 8.1] Add a shim to Guzzle 6 for PHP 8.1 compatibility has landed.
Comment #91
alexpottThe last commit https://git.drupalcode.org/project/drupal/-/merge_requests/937/diffs?com... is to work out how and if #3238452: Exception messages must default to an empty string not a NULL for PHP 8.1 is actually necessary.
Comment #92
daffie CreditAttribution: daffie commentedComment #93
daffie CreditAttribution: daffie commentedComment #94
daffie CreditAttribution: daffie commentedComment #95
daffie CreditAttribution: daffie commented#3236769: PoItem causes deprecation errors on PHP 8.1, #3233010: drupal_phpunit_contrib_extension_directory_roots() passes NULL to file_exists() causing deprecations in PHP 8.1 and #3232695: Only process values in config entity query conditions for operators that have values have landed.
Comment #96
daffie CreditAttribution: daffie commented#3238452: Exception messages must default to an empty string not a NULL for PHP 8.1 has landed.
Comment #97
andypostFiled 2 new patches - it makes my watchdog clean
- #3238941: \Drupal\big_pipe\Render\BigPipe::splitHtmlOnPlaceholders() causes deprecation errors on PHP 8.1
- #3238942: \Drupal\Core\Routing\RedirectDestination::get() causes deprecation errors on PHP 8.1
Comment #98
daffie CreditAttribution: daffie commentedComment #99
daffie CreditAttribution: daffie commentedComment #100
daffie CreditAttribution: daffie commented#3238942: \Drupal\Core\Routing\RedirectDestination::get() causes deprecation errors on PHP 8.1 has landed and created: #3239270: Update dependencies for 9.3 for vfsStream.
Comment #101
alexpottComment #102
daffie CreditAttribution: daffie commented#3239295: Passing NULL to the $replace parameter of str_replace() and preg_replace() triggers a deprecation in PHP 8.1, #3239294: Passing NULL to the limit argument of preg_split triggers a deprecation in PHP 8.1 and #3239313: \Drupal\views\Controller\ViewAjaxController causes deprecations on PHP 8.1 have landed.
Comment #103
daffie CreditAttribution: daffie commentedComment #104
daffie CreditAttribution: daffie commentedComment #105
andypostmoved to done #3239287: Fix \Drupal\Core\Extension\ModuleDependencyMessageTrait to not cause deprecations in PHP 8.1
filed
- #3239552: Improve hash() calculation for PHP 8.1
- #3239553: \Symfony\Component\Routing\Route::getRequirement() causes deprecation errors on PHP 8.1 when it returns NULL
Comment #106
andypostAdded #3239556: Fix return type of \Drupal\Tests\migrate\Kernel\TestFilterIterator::accept()
Comment #107
andypostadded #3239558: Properly use state counter in \Drupal\search_embedded_form\Form\SearchEmbeddedForm
Comment #108
andypostFixed
#3239292: Missing configuration in KernelTests causes deprecations in PHP 8.1
#3239552: Improve hash() calculation for PHP 8.1
#3239556: Fix return type of \Drupal\Tests\migrate\Kernel\TestFilterIterator::accept()
#3239558: Properly use state counter in \Drupal\search_embedded_form\Form\SearchEmbeddedForm
#3239287: Fix \Drupal\Core\Extension\ModuleDependencyMessageTrait to not cause deprecations in PHP 8.1
Comment #109
andypostFiled upgrade for SF (has some 8.1 fixes) and the rest #3239772: Update dependencies for Drupal 9.3
Comment #110
daffie CreditAttribution: daffie commentedComment #111
andypostFixed
Comment #112
andypostmoved to done
Comment #113
andypostThe biggest change has done #3232673: \Drupal\Core\Entity\EntityInterface::label() can return a NULL
Comment #114
andypostPHPCS also should create new release soon as milestone finished https://github.com/squizlabs/PHP_CodeSniffer/milestone/26
Comment #115
andypostLots of follow-ups files by Alex
Meantime I find this 2 issues are priority as prevents lots of noise running tests
- #3240191: \Drupal\KernelTests\KernelTestBase::bootKernel() causing deprecations in PHP 8.1
- #3240192: \Drupal\user\AccountForm::buildEntity() causing deprecations in PHP 8.1
Comment #116
daffie CreditAttribution: daffie commentedPHP has released PHP 8.1 RC3. See: https://www.php.net/archive/2021.php#2021-09-30-1
Comment #117
daffie CreditAttribution: daffie commentedWe are getting a number of explode() warnings: "Exception: Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated Drupal\comment\CommentViewBuilder->buildComponents()() (Line: 127)"
Could we do a testbot run with PHP 8.1-RC3.
Comment #118
andypostJust queued test run on updated images (labels are not deployed yet)
Comment #119
andypost@daffie this new failure will gone after #3240167: \Drupal\comment\CommentStorage::getMaxThread() and \Drupal\comment\Entity\Comment::getThread() cause deprecations on PHP 8.1
Comment #120
andypostFiled #3240360: Clean-up usage of http-client in \Drupal\Tests\views\Functional\ViewAjaxTest::testNonAjaxViewViaAjax()
Comment #121
andypostFiled #3240361: \Drupal\user\Entity\User::checkExistingPassword() causes deprecations on PHP 8.1
Comment #122
andypostComment #123
andypostComment #124
andypostNext blocker #3240456: Allow E_DEPRECATED deprecations to be skipped so we can test on PHP 8.1
Comment #125
daffie CreditAttribution: daffie commentedThese issue have landed. Could we do a reroll? Hopefully with a testbot with RC3
Comment #126
andypost7 new child issues filed
Comment #127
andypostand 2 more
- #3240955: \Drupal\media\Plugin\Filter\MediaEmbed::applyPerEmbedMediaOverrides() triggers deprecations in PHP 8.1
- #3240958: template_preprocess_locale_translation_last_check() causes deprecations on PHP 8.1
Comment #128
alexpottI *think* that we now have sub issues for every single change in the meta merge request. The only thing we're missing is a Mink and a MinkSelenium2Driver upgrade issue. The Mink maintainer has said that there will be a release soon as I've resolved their blockers for that.
Comment #129
alexpottComment #130
alexpottComment #131
alexpottUpdating outstanding list.
Comment #132
daffie CreditAttribution: daffie commented#3241296: core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php triggers deprecations on PHP 8.1, #3241267: Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testOtherMethods() fails due to a type error on PHP 8.1 and #3241268: core/modules/node/tests/modules/node_test/node_test.module cause deprecations on PHP 8.1 have landed.
Comment #133
daffie CreditAttribution: daffie commented#3241280: Fix PHP 8.1 deprecations caused by views code and #3241306: core/tests/Drupal/Tests/Core/Database/ConnectionTest.php fails on PHP 8.1 have landed.
Comment #134
andypostOnly 3 issues left!
Comment #135
alexpottOops there are 4... forgot to make this a parent of one... #3241272: core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php causes deprecations on PHP 8.1
Comment #136
alexpottComment #137
andypostThere's phpcs release compatible with 8.1
https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.6.1
Comment #138
alexpott@andypost let's wait for behat/* until we create a dependency update.
Comment #139
andypostThe last issue is RTBC, updated IS with https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.6.1
Comment #140
andypostI filed another child issue #3242889: Update dependencies for 9.3.x
we could re-purpose it for other updates but I get locally still 2 deprecation notices
Comment #141
alexpottComment #142
alexpottGreen at last.
Comment #143
catchComment #144
alexpottWe are done! PHP 8.1 testing has been enabled for 9.3.x on commit.
All child issues that are required for PHP 8.1 compatibility are fixed, therefore, we can move this meta to fixed as it is complete.
Comment #145
mondrake🎉 great work, thanks a lot to all involved!
Comment #146
andypostI think daily or weekly run of CI 8.1 could be enabled to prevent regressions
Comment #147
andypostComment #148
Gábor Hojtsy@andypost: as @alexpott pointed out in chat, as per https://www.drupal.org/node/3060/qa 8.1 is already being tested on each commit not just daily or weekly. That should definitely help avoid regressions.
Comment #149
andypostOne more child added #3244533: usleep() usage triggers deprecations on PHP 8.1
Comment #151
JayKandariAfter latest upgrade to 9.3.7 with php 8.1, got the strange error mentioned in #12
NOTICE: PHP message: Error: Class "Drupal\Core\Logger\RfcLogLevel" not found in ...
Did composer install after removing `core` && `vendor` folders as well. same issue.
EDIT: Fixed this by restarting `service php8.1-fpm reload`
Comment #152
quietone CreditAttribution: quietone at PreviousNext commentedI just ran into the error message about RfcLogLevel too. See #12.
In my case a Commerce Migrate functional test was working on 9.4.x on one ddev environemnt and failing in another ddev environment The difference was that the working one was using composer 2,
composer_version: "2"
in .ddev/config.yaml and the failing one had no configuration value for composer_version. Once IComment #153
MingsongFatal error with PHP 8.1 and Drupal 9.3.12:
If the field value is empty (''), then following twig template code will triggle that fatal error.
Comment #154
larowlan@Mingsong try
{{ paragraph.field_body.processed }}
Comment #155
MingsongThanks @Lee Rowlands for prompt response.
Yes, using 'processed' instead of the render array will avoid the fatal PHP error.