Problem/Motivation

This issue to collect all todos and updates discovered while making core compatible with PHP 8.0 in #3109885: [meta] Ensure compatibility of Drupal 9 with PHP 8.0 (as it evolves). Issues should be limited to removing dead code, unneeded compatibility layers, etc. that are already present in HEAD.

Add upcoming clean-ups and related issues.

Adopting new language features of PHP 8.0 or 8.1 (like union types, protected property promotion, etc.), is not in scope and should be targeted for 10.1.x instead.

Steps to reproduce

Proposed resolution

Remaining issues
- #3178994: Allow fatal error on PHP 8.0 in LocalStream::stream_open() for fopen()
- #3310307: GDToolkit::save() fails for some custom-local stream wrappers

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

andypost created an issue. See original summary.

andypost’s picture

Issue summary: View changes

#3178998: Update error types and messages for PHP 8 will need to clean-up added conditions

andypost’s picture

gábor hojtsy’s picture

aaronmchale’s picture

Union types are (will be?) a thing in PHP 8:

https://wiki.php.net/rfc/union_types_v2

Maybe this is a good opportunity to go through and add complete return types to most/all functions/methods?

aaronmchale’s picture

Thanks Andy :)

gábor hojtsy’s picture

I *think* this issue was meant to be a cleanup of backwards compatibility code that is left for PHP 7 support / forward compatibility with PHP 8. That is how it got into the Drupal 10 beta requirements.

andypost’s picture

gábor hojtsy’s picture

#3252088: Increase Drupal::MINIMUM_PHP to 8.0.0 landed today.

(That does not in itself means that issues here should be pushed forward, depending on how much divergence should be in Drupal 9.4 vs. Drupal 10. Best to get release manager confirmation here.)

xjm’s picture

Issue tags: +Drupal 10

Now that alpha1 is tagged and we're starting general deprecation removals, we can probably go ahead with this work as well.

xjm’s picture

Oh, re: #6, we would start adding union types and similar to 10.1.x at the earliest. Drupal 9.4 and Drupal 10 need to have the same public API, which means that public API needs to be compatible with PHP 7.3. Futhermore, adding typehints to existing code would need to be done with BC and deprecation.

xjm’s picture

Title: [META] Various updates when PHP 8.0 will become required » [meta] Remove dead code/unneeded compatibility layers now that PHP 8.1 is required
Issue summary: View changes

Just reiterating that work in this issue should be limited to removing dead code paths where older PHP versions are handled separately. PHPUnit often requires us to add such compatibility layers, for example.

xjm’s picture

longwave’s picture

Added two child issues:

#2532228: Use RecursiveCallbackFilterIterator instead of the $acceptTests parameter forwarding - PHP 5.3!
#3001920: Investigate PHP 7.3 workarounds

The MySQL driver has some comments about PHP 7:

    if (!$this->connection->inTransaction()) {
      // On PHP 7 $this->connection->inTransaction() will return TRUE and
      // $this->connection->rollback() does not throw an exception; the
      // following code is unreachable.
    if ($this->connection->inTransaction()) {
      // On PHP 7 $this->connection->inTransaction() will return TRUE and
      // $this->connection->commit() does not throw an exception.

Not sure we have an issue for these.

roderik’s picture

I believe #3310307: GDToolkit::save() fails for some custom-local stream wrappers fits the bill of "remove unneeded compatibility layers".

Though I'm not claiming it's a must-have for D10, because AFAICT it could have been removed for PHP7 / D9 already and apparently noone encounters this issue...

roderik’s picture

quietone’s picture

I came across #1210798: In PHP 5.4+, html_entity_decode() doesn't decode invalid numeric entities which lead me to discover there are checks for PHP v 5.4 in core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php and core/tests/Drupal/Tests/Component/Utility/XssTest.php.

I haven't made an issue to remove those checks (I am focusing on something else right now) but noting it here in the hopes I come back or someone else picks this up.

spokje’s picture

Created #3321945: Remove PHP < 5.4.0 checks to deal with the PHP 5.4 checks as discovered by @quietone in the comment above me.

spokje’s picture

andypost’s picture

Version: 10.0.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.