Problem/Motivation

I just noticed this error in my server log:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'language' at row 1: INSERT INTO "visitors" ("bot", "visitors_ip", "visitors_uid", "visitors_title", "visitors_user_agent", "config_browser_engine", "config_browser_name", "config_browser_version", "config_client_type", "config_device_brand", "config_device_model", "config_device_type", "config_os", "config_os_version", "visitor_id", "visitors_url", "visitors_referer", "route", "visitors_path", "server", "config_resolution", "config_pdf", "config_flash", "config_java", "config_quicktime", "config_realplayer", "config_windowsmedia", "config_silverlight", "config_cookie", "pf_network", "pf_server", "pf_transfer", "pf_dom_processing", "pf_dom_complete", "pf_on_load", "pf_total", "visitor_localtime", "visitors_date_time", "language") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20, :db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23, :db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27, :db_insert_placeholder_28, :db_insert_placeholder_29, :db_insert_placeholder_30, :db_insert_placeholder_31, :db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34, :db_insert_placeholder_35, :db_insert_placeholder_36, :db_insert_placeholder_37, :db_insert_placeholder_38); Array ( ... [:db_insert_placeholder_38] => gsw ) in Drupal\visitors\Service\TrackerService->writeLog() (line 36 of /var/www/mysite/web/modules/contrib/visitors/src/Service/TrackerService.php).

The issue is that the language code ("gsw") contains 3 characters and the "language" field in the database is VARCHAR(2).

Issue fork visitors-3588029

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sah62 created an issue. See original summary.

sah62’s picture

Issue summary: View changes
aayushpathak’s picture

Assigned: Unassigned » aayushpathak

aayushpathak’s picture

Assigned: aayushpathak » Unassigned
Status: Active » Needs review

Hi,
I reviewed the code and current schema, and there is no visitors table defined .
This suggests the error may come from an outdated table.
I also added an update hook to increase the language field length to 12 if the table exists, to handle longer language codes.
Thanks!

bluegeek9 changed the visibility of the branch 3588029-data-too-long to hidden.

bluegeek9’s picture

Status: Needs review » Active
sah62’s picture

ISO 639 language codes are either 2 or 3 characters in length. Expanding the field from VARCHAR(2) to VARCHAR(3) should suffice.