Bug in Connection.php

Wappler Version : 4.5.0
Operating System : OSX
Server Model: PHP
Database Type: MySQL
Hosting Type: Local

All my SA DB queries have started erroring.

dmxConnectLib\/lib\/db\/Connection.php","line":152,"message":"json_decode(): Passing null to parameter #1 ($json) of type string is deprecated","trace":"#0 [internal function]: exception_error_handler(8192, 'json_decode(): ...'

Line 152 reads as $row[$name] = json_decode($value);

changed to $row[$name] = json_encode($value); to resolve.

Hello,
What version of PHP are you using?

Hi @Teodor
PHP 8.1.0

https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation

strlen function expects the first parameter to be of type string . By definition, it does not accept null values (i.e. not declared as ?string nor string|null union type). For historical reasons, PHP allowed passing null , for these parameters. This behavior is inconsistent from user-land functions/methods because they would have thrown a \TypeError exception if null is passed to a parameter type not declared as nullable.

2 Likes

Thanks @NewMedia @Teodor
I reverted to PH 8.0 and the Connection.php back to json_decode($value);
As the issue occurs even when I call a SA that does not have/need any $_GET parameters

Here an updated version of the Connection.php. An extra null check is added to prevent calling json_decode with a null value.

Connection.zip (1.9 KB)

1 Like

This has been fixed in Wappler 4.6

This topic was automatically closed after 47 hours. New replies are no longer allowed.