Modx 3 and php 8.2.26

Hello everyone,

I was developping a custom snippet with php 7 and it was working fine

I recently upgraded my local LAMP development server, it’s now a debian bookworm that comes with php 8.2.26

Today with php 8.2.26 I see several php warnings for deprecated functions when calling getChunk. I also have a fatal error: Uncaught TypeError: json_decode(): Argument #1 ($json) must be of type string
/var/www/www.mysite.dev/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php on line 2465

Since the error occurs in xPDO.php I am not fully sure if it’s my custom code that gives the error or if the php 8.2.26 is the problem

This line gives the fatal error:
if ( !$rows = $c->stmt->fetch( PDO::FETCH_ASSOC ) ){

I see in the server requirements page that php 8 should me supported by modx 3 but i’m not sure about my specific version php 8.2.26

Should I downgrade to php 7 again? Is it normal that php 8.2.26 gives fatal errors?

What exact version of MODX 3 are you using?

Is this line of code in your custom code or in MODX?
Are you sure this is the line that causes the error? It doesn’t seem to match the error message.

If this line throws the error

then the reason for the error is probably that you are calling the function $modx->fromJSON() in your custom code with a wrong value (not a string) as the first parameter.

1 Like

Thank you halftrainedharry

My apologies, I ran “apt upgrade” and there were a bunch of upgrades for php8 that i didn’t install at first

Looks like modx 3…05-pl and my custom code are all working now. I don’t have the error message like before

Thank you once again halftrainedharry!

1 Like