Skip to content

[2.1]: PHP 8.4 compatibility #8676

@Sesquipedalian

Description

@Sesquipedalian

PHP 8.4 deprecates implicit nullable types, meaning that a function signature like this will thow deprecation notices:

function my_func(int $foo = null)
{
    ...
}

Instead, PHP 8.4 requires the int type declaration to be replaced with ?int or int|null. However, neither ?int nor int|null are supported by PHP 7.0, which means that the only way to support implicitly nullable types in a way that is compatible with both PHP 7.0 and PHP 8.4 is to not use type declarations at all.

This breaking change affects the ReCaptcha library we use, and Google has not yet updated the library to fix this.

Moreover, unless Google decides to update the library in a way that stops using implicitly nullable types entirely, it will be impossible for them (or anyone) to add support for PHP 8.4 without dropping support for PHP 7.0.

In light of this, I see three possible responses:

  1. We tweak our copy of the included library to make it compatible with PHP 8.4 until such time as Google updates the official repository with a fix. This will require dropping support for PHP 7.0.
  2. We replace the included library with some other one. This would also require other changes elsewhere in our code, and would require extensive testing. This might or might not require dropping support for PHP 7.0.
  3. We decide not to support PHP 8.4.

I don't think it makes any sense to keep support for PHP 7.0 at the cost of not supporting 8.4, so option three is off the table.

Option 2 might be worth looking into, but it would take time to test and I want to resolve this in 2.1.5.

Option 1, then, seems like the best route forward to me. I don't like the idea of having to make changes to a third party library, but that seems like the lesser evil.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions