Fixed PHP 8.1 Compatibility

Kirby

Well-known member
Affected version
2.2.7 PL 1
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 :)
 
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.
 
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.
 
Been running for 23 hours now after XF 2.2.8 upgrade, works great and fine.
No errors logged
If you're using Centmin Mod, you can also try PHP 8.1.0 with new libgd 2.3.3 version to see how Xenforo image features work with a newer GD PHP library https://community.centminmod.com/th...-php-extension-support-in-123-09beta01.22211/ :)

Bash:
php --ri gd

gd

GD Support => enabled
GD headers Version => 2.3.3
GD library Version => 2.3.3
FreeType Support => enabled
FreeType Linkage => with freetype
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
PNG Support => enabled
WBMP Support => enabled
XPM Support => enabled
XBM Support => enabled
WebP Support => enabled
BMP Support => enabled
AVIF Support => enabled
TGA Read Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 1 => 1
 
Back
Top Bottom