Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm trying to set up an install profile with some dependencies:
dependencies[] = i18n
dependencies[] = i18n_block
dependencies[] = i18n_node
dependencies[] = i18n_string
dependencies[] = i18n_variable
But when i try to create a new site-install with drush, I get the following error:
Starting Drupal installation. This takes a few seconds ... [0.6 sec, 7.49 MB] [ok]
WD system: user module installed. [3.06 sec, 14.61 MB] [info]
WD system: user module enabled. [3.06 sec, 14.61 MB] [info]
WD system: filter module installed. [3.5 sec, 16.12 MB] [info]
WD system: filter module enabled. [3.51 sec, 16.12 MB] [info]
WD system: field_sql_storage module installed. [3.62 sec, 16.26 MB] [info]
WD system: field_sql_storage module enabled. [3.62 sec, 16.26 MB] [info]
WD system: field module installed. [3.88 sec, 17.03 MB] [info]
WD system: field module enabled. [3.88 sec, 17.03 MB] [info]
WD system: text module installed. [4.15 sec, 17.15 MB] [info]
WD system: text module enabled. [4.15 sec, 17.15 MB] [info]
WD system: node module installed. [4.65 sec, 17.88 MB] [info]
WD system: node module enabled. [4.65 sec, 17.88 MB] [info]
WD system: locale module installed. [5.04 sec, 18.16 MB] [info]
WD system: locale module enabled. [5.04 sec, 18.16 MB] [info]
WD system: block module installed. [5.49 sec, 18.89 MB] [info]
WD system: block module enabled. [5.49 sec, 18.9 MB] [info]
WD system: variable module installed. [5.81 sec, 19.06 MB] [info]
WD system: variable module enabled. [5.81 sec, 19.06 MB] [info]
WD system: i18n module installed. [6.14 sec, 19.57 MB] [info]
WD system: i18n module enabled. [6.14 sec, 19.58 MB] [info]
WD system: i18n_string module installed. [6.53 sec, 19.8 MB] [info]
WD system: i18n_string module enabled. [6.54 sec, 19.87 MB] [info]
WD system: i18n_block module installed. [6.91 sec, 19.99 MB] [info]
WD system: i18n_block module enabled. [6.91 sec, 19.99 MB] [info]
WD system: translation module installed. [7.22 sec, 20.11 MB] [info]
WD system: translation module enabled. [7.22 sec, 20.11 MB] [info]
WD system: i18n_node module installed. [7.63 sec, 20.25 MB] [info]
WD system: i18n_node module enabled. [7.63 sec, 20.25 MB] [info]
WD system: variable_store module installed. [7.98 sec, 20.3 MB] [info]
WD system: variable_store module enabled. [7.98 sec, 20.31 MB] [info]
WD system: variable_realm module installed. [8.33 sec, 20.42 MB] [info]
WD system: variable_realm module enabled. [8.33 sec, 20.42 MB] [info]
WD system: i18n_variable module installed. [8.66 sec, 20.46 MB] [info]
WD system: i18n_variable module enabled. [8.66 sec, 20.46 MB] [info]
Fatal error: Call to undefined method i18n_object_wrapper::strings_update() in /var/www/arendus/seb_d7/sites/all/modules/contrib/i18n/i18n_string/i18n_string.module on line 851
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Call to undefined method i18n_object_wrapper::strings_update() in /var/www/arendus/seb_d7/sites/all/modules/contrib/i18n/i18n_string/i18n_string.module, line 851 [9.25 sec, 21.47 MB]
When i enable the same modules together via admin UI, there's no problem...
Comment | File | Size | Author |
---|---|---|---|
#29 | 1681414-29-i18n-fatal_error_installlll.patch | 7.02 KB | pfrenssen |
Comments
Comment #1
svendecabooterConfirmed. Having the same problem...
Comment #2
torotil CreditAttribution: torotil commentedI also need at least one module in the profile to trigger this bug. I'm attaching a minimal installation profile that triggers the bug, when installed with drush si.
The profile depends on i18n_block and i18n_node and contains a module that implements hook_node_info() to declare a single content-type.
Comment #3
torotil CreditAttribution: torotil commentedThis seems to be a regression that was introduced with http://drupalcode.org/project/i18n.git/commit/c27323d (found with git bisect).
Comment #4
torotil CreditAttribution: torotil commentedHere's a patch that should fix those errors. The problem was that the drupal_static cache for i18n_object_info() wasn't emptied when new submodules of i18n were enabled. So even though some hooks from i18n_node were called i18n_object_info() didn't know about i18n_node which lead to the bug.
The patch adds drupal_static_reset() calls so that i18n_object_info() always sees the current set of modules.
Comment #6
torotil CreditAttribution: torotil commented#4: 1681414_static_reset_in_hook_install.patch queued for re-testing.
Comment #8
torotil CreditAttribution: torotil commentedtrying again with correct version.
Comment #9
torotil CreditAttribution: torotil commented#4: 1681414_static_reset_in_hook_install.patch queued for re-testing.
Comment #10
Nebel54This patch worked perfectly for me. The coder module does not raise any new issues and a test-site on the same platform (using i18n) did not break ;)
Comment #11
swentel CreditAttribution: swentel commentedThe patch contains whitespaces, those should be fixed first
Whitespace
Whitespace
Whitespace
Whitespace
Comment #12
torotil CreditAttribution: torotil commentedPatch without whitespace.
Comment #13
torotil CreditAttribution: torotil commentedComment #15
swentel CreditAttribution: swentel commentedGreat! (it will come green I presume)
Comment #16
Nebel54Thanks to both of you!
@swentel: Did you use a tool to find and document the whitespaces in the patch? I tried drupalcs now, which can check the coding standards in the patched files, but not in the patch itself...
Comment #17
swentel CreditAttribution: swentel commented@Nebel54 - http://drupal.org/project/dreditor
Comment #18
torotil CreditAttribution: torotil commented#12: static_reset.patch queued for re-testing.
Comment #19
webflo CreditAttribution: webflo commentedI think its better to reset i18n_object_info in a central location rather then any module that implements hook_i18n_object_info.
@torotil: I tested this patch with your i18n installation profile.
Comment #20
swentel CreditAttribution: swentel commentedOh yeah, that's much cleaner!
Comment #21
webflo CreditAttribution: webflo commentedCommitted the last patch. Commit 659c880 on 7.x-1.x
Thanks!
Comment #23
betz CreditAttribution: betz commentedAh, i just had this issue, updated to latest version and fixed.
Life can be good :)
Thanks!
tom
Comment #24
jisuo CreditAttribution: jisuo commentedSeems to be a regression bug here.
Using i18n 7.x-1.10 and Drupal 7.26
I have install profile with:
And I get this error when installing a new site:
The i18n.module file cotains the patch:
Comment #25
timaholt CreditAttribution: timaholt commented+1 to @jjsuo
Comment #26
pfrenssenI can confirm the above two reports that this is still failing in certain conditions. Reopening the issue.
Replicating the problem
A simple way to replicate this issue is to make an install profile containing i18n_field, i18n_string and the Message module. When this install profile is enabled the following error occurs:
Short summary of why this is still failing
If a module that uses an i18n object in its hook_install() or hook_enable() phase is enabled at the same time as the module that provides the object the error occurs. The current fix resets the
i18n_object_info
cache too late.The gory details
Let's use the Message module as an example. In
message_install()
a field is created:i18n_field
andi18n_string
modulesmodule_enable()
will loop over the modules that need to be enabled, and will enable the i18n modules before the Message module because of the alphabetical order.i18n_object_info
cache is cleared inhook_modules_enabled()
which only runs after all modules have been enabled.field_create_field()
(see code snippet above).i18n_field_field_create_field()
is invoked, which in turn callsi18n_field_field_update_strings()
. Both of these hooks have been enabled just prior.i18n_field_field_update_strings()
callsi18n_string_object_update()
which relies on the object, but since the i18n object cache has not been reset yet this doesn't yet contain the object. Kapow, fatal error.Solution
The solution is to clear the object cache during
hook_enable()
rather than inhook_modules_enabled()
. Earlier iterations of the patch took this approach (ref #12), but usedhook_install()
instead which is problematic as the fatal error might reoccur after disabling a module, clearing the cache, and then enabling it again.This earlier approach was rejected in #19 and replaced with the current approach because it is cleaner and results in much less code, but unfortunately it does not cover this particular use case if the object being used during
hook_enable()
orhook_install()
.I suggest we still keep the original patch in because otherwise we would break contrib. Third party modules that provide i18n object are not yet using this fix, so they would at least still have partial protection against this bug with the original approach. It would be good to make followup issues in third party modules to notify them of the problem.
Patch coming up in a few minutes.
Comment #27
pfrenssenComment #29
pfrenssenSo, apparently it is illegal to upload a patch called "*install.patch", renaming and giving it another shot.
Comment #30
pfrenssenComment #31
bertramakers CreditAttribution: bertramakers commentedI reviewed this patch and it fixed the issue.
Full disclosure: Me and pfrenssen work together, and we needed this fix because our Simpletests failed to start because of this issue.
Comment #32
jisuo CreditAttribution: jisuo commentedI installed the patch, but I still got the same error. Is there anything else I need to do?
Comment #33
mxr576I've just applyied the patch and apparently this solved my same issue! Thanks for the patch!
Drupal 7.31
i18n 7.x-1.11
Comment #34
torotil CreditAttribution: torotil commentedWhen installing a module these are the hooks invoked in order:
Flushing the cache in hook_modules_enabled() might simply be too late for some cases. The only way to be sure that the cache is flushed in time is to do it either in hook_install() or hook_enable() - depending on the module's needs.
hook_modules_installed() might be fine too with a sufficiently low module weight or a hook_module_implements_alter() that gets sure that the cache is flushed before any other hooks are called.
Also I'm wondering if this isn't something that drupal core should or would take care of. I guess it's a common need to refresh static caches during module_enable().
Comment #35
torotil CreditAttribution: torotil commentedSince I'm not seeing any better option as described thoroughly in #26, I'm setting this to RTBC.
Comment #36
Jose Reyero CreditAttribution: Jose Reyero commentedHonestly, I appreciate all this thorough research, but this is just too ugly, and also not a generic solution if any module implementing this hooks needs to do the same, I don't feel like committing it..
There should be some better solution.
Just wondering... but there are a lot of things going on after each module is enabled, can't we find a better place to do the static clean up? For instance, wouldn't it make sense/work to rebuild it after hook_entity_info() is invoked? or module_implements_alter... or anywhere..
See https://api.drupal.org/api/drupal/includes%21module.inc/function/module_...
Please, tell me there's some better solution for this issue... :-/
Comment #37
torotil CreditAttribution: torotil commentedI think that the only proper solution is to patch core's module_enable function to do a global drupal_static()-reset before calling the install method of the module.
There was also a similar issue for payment and I'll bet i18n and payment are not the only modules. Maybe together we can build enough momentum to get that fixed in D7.
Comment #38
torotil CreditAttribution: torotil commentedComment #39
Rob C CreditAttribution: Rob C commentedPossibly related: #1891356: D7: Reset drupal static caches when a module is enabled or disabled. #2403851: Drupal Commerce is broken with Rules 7.x-2.8 #2352739: Reset static caches on module enable/disable. and so on.
Comment #40
JvE CreditAttribution: JvE commented