Hello,
I have a fatal error during install (I tried twice) due to the missing table "user__allowed_languages" :
The website encountered an unexpected error. Please try again later.
User error: Drupal\Core\Database\DatabaseExceptionWrapper thrown while calling __toString on a Drupal\Core\StringTranslation\TranslatableMarkup object in /var/www/html/mysite-d8/web/core/lib/Drupal/Core/Database/Connection.php on line 686: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mysite.user__allowed_languages' doesn't exist
I guess that during the installation, Allowed Languages module has to create this table and thus should not rise this error. My website has the right to create tables in MySQL, so I guess there is not environement reason that this missing table is not created. Actually, seeing source code of the module, I don't see what lines of code create the table ?
This problem may be due to the release of 18 March 2019 because I had tested the module a few weeks ago and he worked perfectly.
Thanks for your answer and your work !
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | allowed_languages_missing_table.patch | 2.39 KB | bingol@ciandt.com |
| #13 | status_report_error.png | 21.86 KB | dromansab |
| #9 | missing-table-during-installation-3042168-9.patch | 1.02 KB | rob230 |
Comments
Comment #2
nterbogt commentedAre you able to provide more information like which URL you were using when you saw the error? What actions you were performing?
I've installed the module on a clean site through both drush and the UI and am unable to replicate it.
Thanks.
Comment #3
salvor_hardin commentedIt was during the installation (composer then UI)
Comment #4
salvor_hardin commentedComment #5
wwwahe commentedSame here while installing the module :
Comment #6
wwwahe commentedThe module seems to install only if the default language is 'en'
Comment #7
nterbogt commentedThank you for the update. I'll investigate further and see where we are having issue.
Comment #8
nterbogt commentedI've tested this:
* as a clean install on 'en' site.
* as a clean install on 'es' site.
* as an uninstall/reinstall on both the of the above.
I'm yet to encounter the issue. I need someone experiencing the issue to replicate and investigate.
Comment #9
rob230 commentedThis is so strange because I got the same problem when I installed the module (also when using a non-default language as the interface language). But then I couldn't get it to happen again, even after uninstalling the module and clearing the caches and running cron. Every subsequent attempt to install the module in any language succeeded and the table was created.
I think the error might be because the entity updates haven't been run, so the new table hasn't been created yet. But I don't know why sometimes it does create it and sometimes it doesn't.
I've attached a patch which causes the entity updates to be run after install, but I can't be 100% sure that it fixes the issue since I cannot get the issue to occur any more.
Comment #10
wwwahe commentedWe still have this issue on new install.
The patch didn't solve the problem.
We need to create manually the table
I post here the query for people like me who get a broken website, so at least they could uninstall the module :
Regards
Comment #11
nterbogt commentedAs with a number of you, I have run the install again and again... as english, spanish and french. Installing the module via the UI and drush and I just don't seem to be able to reproduce the error. I've rebuilt completely new docker environments to test it; and still can't reproduce the error.
If someone could screen capture the process they use to throw the error, I would love to see it.
My best guess is that it's a problem with specific implementations where Drupal fails to create the database table on install. This isn't necessarily _this_ modules issue and could be caused by any number of other modules that hook into the install process.
If anyone on here can reproduce the issue consistently... could I please get a copy of your composer.json? Could you also see if you can reproduce the issue with just drupal core and allowed languages... nothing else installed or available?
Comment #12
dromansab commentedHi,
I can reproduce the error with Drupal 9. Table is not created and the patch does not work.
I created the table manually (as wwwahe recommends). The crash disappears but the error is still displayed at Status report page:
Regards,
Dani
Comment #13
dromansab commentedComment #14
kriboogh commentedI was having a similar problem with a custom module I'm writing, that also updates the user entity with a base field that has cardinality set to -1.
This is how I solved it: (replace with your module, and with your field)
/**
* Implements hook_module_preinstall().
*
* When updating the existing User entity with new base fields having
* cardinality of -1 (unlimited), it's upto the entityDefinitionUpdateManager
* to create the dedicated table. This however happens to late in the module
* install process done by the ModuleInstaller.
*
* This is only exceptionally the case when extending the user entity.
*
* When the entitytypemanager is called for fetching the field definitions,
* deeper down the line a cache id is generated with the current user. This
* cache id creation triggers the fielddefinitions of the user entity type to
* be collected, but at this stage, although the definitions are updated, the
* database is not. The following load on the entity storage of user, causes
* the map data to entity call to fail since it tries to find the dedicated
* table.
*
* To solve this, we need to create the database before the module intaller
* loops over all entity definitions.
*/
function _module_preinstall($module) {
if ($module == '') {
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
$entity_field_manager = \Drupal::service('entity_field.manager');
$update_manager = \Drupal::entityDefinitionUpdateManager();
$entity_type_manager = \Drupal::entityTypeManager();
$entity_type_manager->clearCachedDefinitions();
$entity_type = $entity_type_manager->getDefinition('user');
$definitions = $entity_field_manager->getFieldStorageDefinitions($entity_type->id());
// You should do this for all your new custom fields.
$field_name = "";
$update_manager->installFieldStorageDefinition(field_name, $entity_type->id(), $module, $definitions[$field_name]);
}
}
Comment #15
ricky.bertram commented#14 Worked like a charm for me, thank you!
Comment #16
grimal commentedSame problem here with 2.x, no table and "Mismatched entity and/or field definitions" after table creation.
I've manually created the table as #10, then uninstalled the module and re-enabled it to fix the "Mismatched entity" error.
Comment #17
bingol@ciandt.com commentedComment #18
heddnAre there any recent reports of this on the 2.x branch?
Comment #19
kwolford121 commentedIf I download and enable version 2.0.0, then navigate to `/admin/people`, I get the error message below (I removed my database name since it wasn't relevant). It seems the table isn't created when the module is installed -- `allowed_languages.module` is empty. After applying the code in patch #17 to that file, then the module works fine.
I'm on Drupal 10.3.10 and PHP 8.1.13, by the way. (Please let me know if any more information would be helpful.)
The error on my site: