Cscart Latest Version with PHP 8.1

Hello everyone,
I have a couple of days, that upgraded the version of PHP to 8.1.x *CS-Cart version 4.17.x)

Now, we are trying to pull cs-cart orders via API, but we are facing the below error:

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/ on line 229
CSCart is upgraded to last version.

Is there any fix for that or any ideas how to fix?

thanks in advance

One more issue that we gave is this:

I am trying to do a quick search like this:

Screenshot by Lightshot but I could not see any results… although the tabs have found. The PHP version is now 8.1.x (CS-Cart version 4.17.x Ultimate), but we do realize some small bugs I guess like this one. Any ideas?

Thank you for your time.


It seems that this Deprecated notice is missing from the change log of changes in PHP:
As a result, our developers simply overlooked this case.

I have created a new task for the developers to fix this. In the meantime, you can make the following changes to work around this problem:
Replace the following code:

    list($email, $api_key, $token) = array_map('trim', [$email, $api_key, $token]);

with this code:

    $email = empty($email) ? '' : trim($email);
    $api_key = empty($api_key) ? '' : trim($api_key);
    $token = empty($token) ? '' : trim($token);

in the app/functions/fn.users.php file.


I’m getting several of these messages in my PHP error log with PHP 8.1.

Deprecated: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in ///public_html/app/functions/fn.control.php on line 1174

Please provide exact steps on how to reproduce this issue.

This is already fixed with #33767.

$request_path = rtrim((string) @parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');

1 Like

Yes, I confirm this.


The problem in authorization for API requests is fixed in the 4.18.1 release.
To fix you can use the patch:

You can read about how to apply the patch in our documentation: How To: Apply a DIFF File — CS-Cart 4.17.x documentation