Got SQL error when saving the feedbacks in other languages

Created on 29 March 2023, over 1 year ago
Updated 31 March 2023, over 1 year ago

I installed and enabled the admin_feedback module,and also set up the Drupal translations., everything looked good.

But the langcode field of the admin_feedback and admin_feedback_score tables was still VARCHAR(2), which I think should be VARCHAR(32). So when I saved the feedbacks, I got the SQL Error in the watchdog,

"Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'langcode' at row 1: INSERT INTO "admin_feedback" ("nid", "langcode", "created", "feedback_type", "feedback_message") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 291 [:db_insert_placeholder_1] => zh-hans [:db_insert_placeholder_2] => 1680110630 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => ) in Drupal\admin_feedback\Controller\AdminFeedbackController->insertFeedback() (line 108 of /var/www/drupal/web/modules/contrib/admin_feedback/src/Controller/AdminFeedbackController.php).

I'm wondering if I missed some configuration steps, please help.

Thank you so much.

🐛 Bug report
Status

Fixed

Version

2.5

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Xingwu Chai
  • 🇬🇷Greece bserem

    Hello @Xingwu Chai,
    Can you please some more information with me on this one? It shouldn't be hard to fix, but I want to fix it right.

    1. What language are you using?
    2. What language-code does that language have?

    It's true that we only thought of 2-digit langcodes (en, fr, el, es, de, zh, ja and so on) which as it seems might not allow some langcodes that use 5 digits (ca-ES, el-GR, zh-CN etc).

    Anything you can share with me will speed things up. I expect it would be an easy-ish fix.

    Thanks

  • Assigned to bserem
  • 🇬🇷Greece bserem

    I was able to reproduce this using a custom language with a custom langcode and I also inspected core tables and saw that they use varchar(12).
    An update is on the way.

  • Status changed to Fixed over 1 year ago
  • 🇬🇷Greece bserem

    8.x-2.6 released. Fixes the problem for new and existing installations.

  • Dear @bserem,

    I'm in North America, sorry I was not able to answer your questions sooner.
    I just tried 8.x-2.5, it works perfectly.
    Thank you so much for your quick action on this, I really appreciate it.

  • 🇬🇷Greece bserem

    No worries, timezones are a thing I know. Glad we could sort this out and many thanks for letting me know of the issue.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024