Fixed PHP 8.1 Compatibility

Affected version
2.2.7 PL 1

Kirby

Well-known member
Probably already known:

It seems like XenForo ist currently not compatible with PHP 8.1 due to missing return type declarations on many methods, most notably on classes implementing core interfaes like \ArrayAccess

This does generate error messages like
Code:
An exception occurred: [ErrorException] [E_DEPRECATED] Return type of XF\Session\Session::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/XF/Session/Session.php on line 177
when running in development mode.

While PHP 8.1 is still a a few month away from stable, it would be nice to have this resolved before release date :)
 

Chris D

XenForo developer
Staff member
The changes are fairly extensive and may also apply to third party dependencies which we may need to manually patch so, yeah, we're aware and it's mostly in hand.

We may not be able to guarantee support by the stable release. A future release announcement will mention PHP 8.1 when compatibility is added.
 

Chris D

XenForo developer
Staff member
XF 2.2.8 adds initial support for PHP 8.1.

I strongly suspect there will be some underlying things we have missed, but I'm currently running it in development with no obvious issues thus far.

We wouldn't recommend switching to PHP 8.1 in production but we do call on as many people as humanly possible to test this in staging/testing servers so we can cover off any lingering incompatibilities.
 
Top