Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP8] SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'url' at row 1 #372

Open
anasmoiz opened this issue Dec 10, 2021 · 2 comments

Comments

@anasmoiz
Copy link

Hello,

When we are running the script with PHP 8.0 and we receive the following error.

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'url' at row 1

If we downgrade the version to PHP 7.3 or 7.4, it works perfectly I can see this issue was previously reported #354 as well but was closed without providing an actual solution.

Please note that this is not happening with every site hosted on PHP 8.0 but with a few. if you guys need any details or access to replicate this please let us know, we would really like to solve this issue with your team.

@smissaertj
Copy link

I can confirm the above.

How did you deal with this @anasmoiz ? Did you find a workaround of any kind?

@alex-umani
Copy link

It's not a solution, but I found a bit of a workaround. The problem is that in PHP 8, the PDO class switched from defaulting in SILENT mode to defaulting to EXCEPTION mode (https://php.watch/versions/8.0/PDO-default-errmode)

It doesn't solve the underlying problem (you are trying to insert invalid data to the database), but you can get it to ignore the errors and continue if you add the following line to srdb.class.php:

$params[ PDO::ATTR_ERRMODE ] = PDO::ERRMODE_SILENT;

Insert that around line 558, right before they explicitly set ERRMODE to EXCEPTION when the code is running in debug mode.

It's gotten the code running for me again. Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants