I upgraded my site from Drupal 7 to Backdrop and I get the following error when I try to create a new user account.

EntityStorageException: SQLSTATE[HY000]: General error: 1364 Field 'language' doesn't have a default value in EntityDatabaseStorageController->save() (line 676 of /app/core/modules/entity/entity.controller.inc).

 

Thank you in advance for any assistance.

Accepted answer

I looked at the database and verified that the default value of the language column is not NULL.

I ran this sql command to change the column to be an empty string.

ALTER TABLE users ALTER language SET DEFAULT '';

I know directly editing the database is not usually the best approach, but it did fix the error and I can now edit and create users without any issue.

Comments

klonos's picture

Hello  👋

Thanks for taking the time to report this 👍 ...that sounds like a bug, so I've created a bug report for it in our issue queue https://github.com/backdrop/backdrop-issues/issues/4716 

Can you please provide more information re the D7 site? I am assuming that it was a multilingual site; is that correct? Also, can you list relevant (language-related) core and contrib modules that may have been installed, as well as any relevant settings?

Thank you once again.

indigoxela's picture

Can you please provide more information re the D7 site?

Yes, please. My first question: did you have Entity Translation module installed?

Which fields - if any - are attached to your user profiles?

Hi indigoxela,

Thank you for the quick response.

1. I do not have the Entity Translation module installed, but I do have the Content Translation module installed.

2. User profiles have just the default fields of User name and password, Timezone

indigoxela's picture

Hi cedewey,

if you add a new user, is there a field "Language settings" in that form (admin/people/create)?

What happens if you open a form to edit an existing user (user/XX/edit)? Is the field there and can you save that form?

How does your locale.settings.json look like? You can export it on admin/config/development/configuration/single/export. Choose "Configuration" and "Locale settings".

What is the default language of your site (admin/config/regional/language)? Are languages enabled or disabled?

  1. When I add a new user there is no "Language settings" field
  2. When I edit an existing user this no "Language settings" field
  3. Locale Settings are
    
    {
        "_config_name": "locale.settings",
        "language_negotiation_url_prefixes": {
            "en": ""
        },
        "language_negotiation_url_domains": {
            "en": ""
        },
        "_config_static": true,
        "language_negotiation_session_parameter": "language",
        "language_negotiation_url_part": "path_prefix",
        "language_negotiation_url_type": "language",
        "language_providers_weight_language": {
            "locale-url": 0,
            "locale-session": 1,
            "locale-user": 2,
            "locale-browser": 3,
            "locale-interface": 4,
            "locale-url-fallback": 5
        },
        "cache_length": 75,
        "field_language_fallback": true,
        "translate_english": false
    }
  4. English is the default language and enabled. There are no other languages listed.

Thanks!

 

indigoxela's picture

Hm... I'm running out of ideas.

General error: 1364 Field 'language' doesn't have a default value

It does - it's an empty string. The table structure of the "users" db table didn't change in Backdrop.

Is this the only problem you encountered on that site or are there other ones?

Did the upgrade from Drupal run smoothly or were there any errors? (If you still remember.)

Which contrib modules do you have installed?

The Drupal installation ran without any errors. I haven't found any other errors on the site from clicking around on the site.

The status report page looks all good.

Looking at the Recent log messages report, I see the following critical errors

EntityStorageException: SQLSTATE[HY000]: General error: 1364 Field 'language' doesn't have a default value in EntityDatabaseStorageController->save() (line 676 of /app/core/modules/entity/entity.controller.inc).

PDOException: SQLSTATE[HY000]: General error: 1364 Field 'language' doesn't have a default value: INSERT INTO {users} (language, uid, name, pass, mail, signature, signature_format, created, access, login, status, timezone, picture, init, data) VALUES (default, :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); Array ( [:db_insert_placeholder_0] => 1118 [:db_insert_placeholder_1] => clayton [:db_insert_placeholder_2] => $S$EdxRD0uWVy3fdlF.anm/kU8CMXtrHKTOFG82tuisXlKw0MhliDCv [:db_insert_placeholder_3] => clay********@ri*****.net [:db_insert_placeholder_4] => [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1603481632 [:db_insert_placeholder_7] => 0 [:db_insert_placeholder_8] => 0 [:db_insert_placeholder_9] => 1 [:db_insert_placeholder_10] => America/New_York [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => lay********@ri*****.net[:db_insert_placeholder_13] => a:1:{s:7:"contact";i:1;} ) in backdrop_write_record() (line 8139 of /app/core/includes/common.inc).

Error: Call to a member function bundle() on null in node_access() (line 2715 of /app/core/modules/node/node.module).

The site has one contrib module - the Poll module.

indigoxela's picture

Not that it explains much, but can you post your exact MariaDB/MySQL version here?

You find it at /admin/reports/status.

Sure thing, it's version 5.7.29

Also, here is some additional info from the site owner, in case that's helpful.

I think the language settings were always English but I do recall having to alter settings in the db -- this was a long time ago -- I can't even recall from what to what. The site does include some Japanese text, not sure if that is an issue. I may have experimented with a module for allowing users to change the drupal UI language? Sorry I don't remember more.

indigoxela's picture

...but I do recall having to alter settings in the db...

...may have experimented with a module for allowing users to change the drupal UI language

Ouch!

Do you have access to the database? PhpMyAdmin or something? Are you able to inspect the users table structure and contents? Maybe it's messed...

I do! However, I'm not very well versed in database structures so I'm not sure if I would know what to look for. If you are available and interested, perhaps we could look at it together? This is a side project with a modest budget, but I'd be happy to compensate you for your time and expertise to the extent I can. We could continue the conversation by email - claytondewey@riseup.net

indigoxela's picture

I'm not very well versed in database structures

The first thing to check is the default value for the "language" column in table "users".

Here's a screenshot from PhpMyAdmin to compare:

pma screenshot

The most interesting thing is the default value - is it NULL in your database? (Note: your collation might be different, but that's not relevant here.)

And also inspect the actual values (Browse tab). Which values do existing users have?

If you are available and interested...

I'm afraid, I'm not available.

I looked at the database and verified that the default value of the language column is not NULL.

I ran this sql command to change the column to be an empty string.

ALTER TABLE users ALTER language SET DEFAULT '';

I know directly editing the database is not usually the best approach, but it did fix the error and I can now edit and create users without any issue.

indigoxela's picture

I know directly editing the database is not usually the best approach, but it did fix the error and I can now edit and create users without any issue.

I'm glad that you were able to fix it! I think in this case it's OK to directly alter the default value, as the empty string is the default in the User module's schema definition.

And the site owner probably messed it before.

If you discover additional problems, maybe the Schema module is useful.

There's no stable release yet (ported recently), but it could help to discover other mismatches.