PHP 8.3 compatibility patch

PaulB

Well-known member
Affected version
2.2.13
This is just a small patch for PHP 8.3 compatibility issues that we've encountered so far.

Notably, XF\BbCode\Renderer\Html attempts to increment a bool in a couple places, a stopSmilies and stopBreakConversion can be either bools or ints. It's not clear to me why they would ever need to be incremented; as far as I can tell, they're never decremented, and those values are never checked. This is probably a bug. Prior versions of PHP would silently refuse to increment bools anyway, so the only incompatibility here is that PHP 8.3 emits a proper warning. The patch preserves the existing behavior, but this is probably unnecessary.

The only other change accounts for a slight change to the phrasing of a deprecation notice that XenForo ignores. XenForo's str_contains test no longer works correctly in PHP 8.3 due to the change in phrasing.
 

Attachments

Thanks for this, Paul. Stopped all the annoying warnings/errors hitting the logs during our PHP 8.3 testing. Hopefully they'll add this to the next 2.2.14 release, as well as 2.3.
 
8.2 would be the version supported in 2.3
Nope 8.3


Code:
https://xenforo.com/community/threads/general-2-3-discussion.216667/page-3#post-1648445
...annoying direct links to post don't seem to work correctly
 
My bad, I found this:
 
I updated to PHP 8.3.2 yesterday and got flooded with these warning errors. Rolled back to 8.2.15 and all is fine.
Given this, I think it's better to wait for 2.3 release and upgrade PHP again.
 
You have the recommended PHP version.
PHP version 8.3.2


+ XF 2.2.13

All ok
Thank You!
 
Last edited:
This is just a small patch for PHP 8.3 compatibility issues that we've encountered so far.

Notably, XF\BbCode\Renderer\Html attempts to increment a bool in a couple places, a stopSmilies and stopBreakConversion can be either bools or ints. It's not clear to me why they would ever need to be incremented; as far as I can tell, they're never decremented, and those values are never checked. This is probably a bug. Prior versions of PHP would silently refuse to increment bools anyway, so the only incompatibility here is that PHP 8.3 emits a proper warning. The patch preserves the existing behavior, but this is probably unnecessary.

The only other change accounts for a slight change to the phrasing of a deprecation notice that XenForo ignores. XenForo's str_contains test no longer works correctly in PHP 8.3 due to the change in phrasing.

If you enable the mode
$config['development']['enabled'] = true;

then errors will appear in the forum logs.
 
My shared hosting hasn't installed 8.3 yet so I'm kind of stuck at 8.2 for now anyway. Hopefully by the time 8.3 becomes the recommended version, they will have it.
 
I am not an expert in PHP, however, I had to come from 7.4 (as listed in my xenforo ACP). Using my cPanel, 8.1.27 is as high as my forum will allow. If I go one more step up to 8.2, I get a 40x page. I could not remember the exact error, as I wanted to get it all back online. I went back to 8.1.27 and it was restored.

However, I do have a question. in my WHM (using AlmaLinux), in the php MultiPHP Manager, I have two tabs "System Settings" and "User Domain Settings". The User Domain Settings has my forum at 8.1 - but the System Settings (server) still has 7.4.

In the Alma Terminal, I ran "convert - version", I got this:
ImageMagick 6.9.12-93 Q16 x86_64 17898

So, does this mean I have conflicts between cPanel 8.1 and WHM (alma) values 7.4, and then this ImageMagick 6.9.12-93. Therefore, maybe I should do a Graceful Reboot of my Alma?

Thank you to anyone in advance

kindly
Donnie
 
I do have a question. in my WHM (using AlmaLinux), in the php MultiPHP Manager, I have two tabs "System Settings" and "User Domain Settings". The User Domain Settings has my forum at 8.1 - but the System Settings (server) still has 7.4.

The "System Settings" PHP Version is what is used by default for new cPanel accounts. What is actually currently being applied to your domain is what you see under "User Domain Settings".

From what you wrote, there are no conflicts in your settings. That being said there is likely no reason to keep your "System Settings" PHP Version on a version lower than the latest actively supported PHP version, which is currently PHP 8.2. Changing your "System Settings" PHP Version to 8.2 means any new account you create will by default be set to PHP 8.2. This will not affect your XenForo install because your "User Domain Setting" PHP Version is what will still be applied to all your existing individual domains.

P.S. If you are running XenForo 2.2.15 you should not have a problem running PHP 8.2.x. Disable your add-ons and check if the issue still remains. If it doesn't re-enable one-by-to find the add-on(s) with the issue(s).
 
I disabled all of my Addons - and no-go. Not sure whats next. I don't think rebuilding them or rebuilding the cache would have anything to do with this.
 
Do users see this issue? Got my first one in the admin log today. been on 8.3 for a few weeks now so i'm surprised it's the first one.
 
Last edited:
Top Bottom