Really annoying bug, took me a while to figure out that countries_i18n is the cause. It was tough to figure out as this module was not related to test in question at all. So countries_i18n was not a dependency to any of the tested modules but by having the module enabled in the parent installation caused the errors. Disabling module before running tests prevents these errors.

The error

WD system: i18n_string module installed. [10.92 sec, 85.81 MB]
PHP Fatal error:  Call to undefined method i18n_object_wrapper::strings_update() in /.../sites/all/modules/i18n/i18n_string/i18n_string.module on line 851
Drush command terminated abnormally due to an unrecoverable error.

Important pieces of the xdebug output

PHP Stack trace:
...
PHP  20. i18n_string_refresh_enabled_modules() /.../sites/all/modules/i18n/i18n_string/i18n_string.module:208
PHP  21. module_invoke() /.../sites/all/modules/i18n/i18n_string/i18n_string.admin.inc:184
PHP  22. call_user_func_array() /.../includes/module.inc:833
PHP  23. countries_i18n_string_refresh() /.../includes/module.inc:833
PHP  24. i18n_string_object_update() /.../sites/all/modules/countries/modules/countries_i18n/countries_i18n.module:100
Drush command terminated abnormally due to an unrecoverable error.
Error: Call to undefined method i18n_object_wrapper::strings_update() in /.../sites/all/modules/i18n/i18n_string/i18n_string.module, line 853 [8.21 sec, 108.52 MB]

I've also attached a patch that should make testbot show these same errors.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikran’s picture

Status: Needs review » Active

Oh that was unexpected pass from the testbot. I've tested this again and the steps to reproduce on fresh install are:

1. enable countries_i18n
2. run any test that enables countries and i18n_string -modules

And now, I have no clue how to create a test that tests aforementioned conditions. Test inside a test?

EDIT: added countries to step 2.

Alan D.’s picture

any test that enables countries

Um, how was countries_i18n enabled without countries or i18n_string!? Also the test you just ran, runs off a clean setup, so everything would be disabled until a test enables it. Unless you are doing something outside of the norm?

There are no statics or any else that is suspect in the sub-module that I can see, so I'm temped to push this into the i18n queues for feedback, although maybe answers to the above two questions may shed some light on this.

PS: Assume that there is a cache issue in the i18n suite somewhere, so flush out the caches if you are disabling modules, then re-enabling modules within a single test. If that fails, try a class registry flush too, or separate tests into individual test cases.

mikran’s picture

Um, how was countries_i18n enabled without countries or i18n_string!?

Dependencies are enabled normally, I just assumed that would happen when doing the step 1.

Unless you are doing something outside of the norm?

I'm doing this

# to get a fresh start
drush si 

# dependencies are enabled here as well
drush en countries_i18n

# the patch I posted in this issue, to enable i18n module in tests too
wget https://drupal.org/files/countries_i18n_tests_failure.patch 
git apply -v countries_i18n_tests_failure.patch 

# this will fail
drush test-run CountriesBaseInstallUnitTest 

drush dis countries_i18n
# now this works
drush test-run CountriesBaseInstallUnitTest 

I think the problem would go away if i18n hooks were implemented right in the countries module and not in a separate sub module.

Related issues I found:
#2082573: PHP Fatal Error Call to undefined method i18n_object_wrapper::strings_update(): I think the resolution here is a bit work-around'ish, could be same issue
#1697384: Call to undefined method i18n_object_wrapper::strings_update(): This is fixed and already included in the latest version

sammuell’s picture

Status: Active » Needs review
FileSize
911 bytes

The culprit is the function countries_i18n_string_refresh() which is defined as a 'refresh callback'.
Firstly, this refresh callback option does not seem to exist anymore on D7. I think it's a leftover from D6.
Secondly, I think it's misnamed, because it's implementing the hook 'i18n_string_refresh' on behalf of the countries module. The entity hooks of the countries_i18n module are not yet defined at this moment, hence the fatal error.
Renaming the function to countries_i18n_i18n_string_refresh() solves the error.

webflo’s picture

Status: Needs review » Fixed

Great catch. Thanks @sammuell

  • webflo committed 206d25f on 7.x-2.x
    Issue #2122299 by mikran, sammuell, webflo: Tests are failing if...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ennorehling’s picture

Execellent work, @sammuell - many thanks!