Unexpected Error if enter number over 9223372036854775807 with 19 digits

Created on 2 April 2013, over 11 years ago
Updated 20 March 2024, 8 months ago

Problem

If you enter a number that is larger than 19 digits the code catches that as an error and give the Drupal error of 'the length may be no greater than 19 digits'. But if you enter a number that is 19 digits and larger than 9223372036854775807 then instead of a Drupal error you get 'The website encountered an unexpected error. Please try again later' and:

PDOException: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value adjusted for column 'field_currency_value' at row 1: INSERT INTO {field_data_field_currency} (entity_type, entity_id, revision_id, bundle, delta, language, field_currency_value) 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); Array ( [:db_insert_placeholder_0] => user [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => user [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 9999999999999999999 ) in field_sql_storage_field_storage_write() (line 448 of /var/www/vhosts/undersun.net/httpdocs/gtest/modules/field/modules/field_sql_storage/field_sql_storage.module).

Proposed resolution

Ideally the module should catch the error and give a Drupal error of 'the size may be no greater than 9,223,372,036,854,775,807'

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom RebDev

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    I'm happy to review any patch provided here. Is this also something for newer Drupal versions?

  • Status changed to Closed: outdated 8 months ago
  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    Tested this on a Drupal 10.2.4 and entering a number bigger than 9223372036854775807 gives the correct warning and does not break the site.
    So this is only related to Drupal 7. As Drupal 7 will be end-of-life soon. I'm not going to put my time in this except if someone can provide a MR.
    Closing this for now. Feel free to open another issue pointing to this one if needed.

Production build 0.71.5 2024