Random WSOD after updating to 1.3
Sometimes clearing caches helps, sometimes not.

Error log shows PHP Fatal error: Class name must be a valid object or a string in /PATH/TO/i18n_translation.module on line 249

Comments

rnyberg’s picture

I'm getting these as well, seems very random

webflo’s picture

Please provide a list of you enabled i18n related modules.

mropanen’s picture

I have all but i18n_select and i18n_forum enabled.

I get this error mostly when trying to translate a node (e.g. node/add/article?translation=51917&target=fi). Sometimes hitting F5 helps, but most of the time it does not.

rnyberg’s picture

I was debugging and found that the $class variable is just NULL for some pages on our site. As a temporary fix, this _seems_ to make things work.

/**
 * Build a translation set from type, data
 */
function i18n_translation_set_build($type, $data = array()) {
  $class = i18n_translation_set_info($type, 'class', 'i18n_translation_set');
  if ( empty($class) ) {
    $set = new i18n_translation_set((array)$data); // hack
  }
  else {
    $set = new $class((array)$data);
  }

  $set->type = $type;
  return $set;
}
webflo’s picture

Can you post the backtrace?

rnyberg’s picture

Could you give me instructions how to do it and I will :)

webflo’s picture

Status: Active » Postponed (maintainer needs more info)

Please read Quick-and-Dirty Debugging for a first introduction.

rnyberg’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Field Translation module was the culprit. Disabling it solved the errors.

webflo’s picture

Component: Miscellaneous » Fields
Status: Closed (fixed) » Needs work

I set this back to needs work because its an error in field translation module.

mropanen’s picture

Version: 7.x-1.3 » 7.x-1.4
Component: Fields » Miscellaneous

Still happens with Field translation disabled. Updated Drupal to 7.12 and i18n to 1.4

Backtrace from xdebug:

PHP Fatal error: Class name must be a valid object or a string in /var/www/html/site/sites/all/modules/i18n/i18n_translation/i18n_translation.module on line 249, referer: http://server/past-present/modern-china/olen-testi
PHP Stack trace:, referer: http://server/past-present/modern-china/olen-testi
PHP 1. {main}() /var/www/html/site/index.php:0, referer: http://server/past-present/modern-china/olen-testi
PHP 2. menu_execute_active_handler() /var/www/html/site/index.php:21, referer: http://server/past-present/modern-china/olen-testi
PHP 3. call_user_func_array() /var/www/html/site/includes/menu.inc:517, referer: http://server/past-present/modern-china/olen-testi
PHP 4. page_manager_term_view_page() /var/www/html/site/includes/menu.inc:0, referer: http://server/past-present/modern-china/olen-testi
PHP 5. ctools_context_handler_render() /var/www/html/site/sites/default/modules/ctools/page_manager/plugins/tasks/term_view.inc:124, referer: http://server/past-present/modern-china/olen-testi
PHP 6. ctools_context_handler_get_render_handler() /var/www/html/site/sites/default/modules/ctools/includes/context-task-handler.inc:42, referer: http://server/past-present/modern-china/olen-testi
PHP 7. ctools_context_handler_default_test() /var/www/html/site/sites/default/modules/ctools/includes/context-task-handler.inc:68, referer: http://server/past-present/modern-china/olen-testi
PHP 8. ctools_context_handler_get_handler_contexts() /var/www/html/site/sites/default/modules/ctools/includes/context-task-handler.inc:88, referer: http://server/past-present/modern-china/olen-testi
PHP 9. ctools_context_load_contexts() /var/www/html/site/sites/default/modules/ctools/includes/context-task-handler.inc:317, referer: http://server/past-present/modern-china/olen-testi
PHP 10. ctools_context_get_context_from_contexts() /var/www/html/site/sites/default/modules/ctools/includes/context.inc:1208, referer: http://server/past-present/modern-china/olen-testi
PHP 11. ctools_context_get_context_from_context() /var/www/html/site/sites/default/modules/ctools/includes/context.inc:1115, referer: http://server/past-present/modern-china/olen-testi
PHP 12. ctools_context_create_entity() /var/www/html/site/sites/default/modules/ctools/includes/context.inc:1081, referer: http://server/past-present/modern-china/olen-testi
PHP 13. entity_load() /var/www/html/site/sites/default/modules/ctools/plugins/contexts/entity.inc:86, referer: http://server/past-present/modern-china/olen-testi
PHP 14. DrupalDefaultEntityController->load() /var/www/html/site/includes/common.inc:7585, referer: http://server/past-present/modern-china/olen-testi
PHP 15. I18nTranslationSetController->attachLoad() /var/www/html/site/includes/entity.inc:204, referer: http://server/past-present/modern-china/olen-testi
PHP 16. i18n_translation_set_build() /var/www/html/site/sites/all/modules/i18n/i18n_translation/i18n_translation.module:28, referer: http://server/past-present/modern-china/olen-testi

Another one, this is from when I try to translate a node:
PHP Fatal error: Class name must be a valid object or a string in /var/www/html/site/sites/all/modules/i18n/i18n_translation/i18n_translation.module on line 249
PHP Stack trace:
PHP 1. {main}() /var/www/html/site/index.php:0
PHP 2. menu_execute_active_handler() /var/www/html/site/index.php:21
PHP 3. call_user_func_array() /var/www/html/site/includes/menu.inc:517
PHP 4. node_add() /var/www/html/site/includes/menu.inc:0
PHP 5. drupal_get_form() /var/www/html/site/modules/node/node.pages.inc:66
PHP 6. drupal_build_form() /var/www/html/site/includes/form.inc:123
PHP 7. drupal_retrieve_form() /var/www/html/site/includes/form.inc:331
PHP 8. call_user_func_array() /var/www/html/site/includes/form.inc:787
PHP 9. node_form() /var/www/html/site/includes/form.inc:0
PHP 10. node_object_prepare() /var/www/html/site/modules/node/node.pages.inc:93
PHP 11. module_invoke_all() /var/www/html/site/modules/node/node.module:961
PHP 12. call_user_func_array() /var/www/html/site/includes/module.inc:819
PHP 13. translation_node_prepare() /var/www/html/site/includes/module.inc:0
PHP 14. field_attach_prepare_translation() /var/www/html/site/modules/translation/translation.module:307
PHP 15. drupal_alter() /var/www/html/site/modules/field/field.attach.inc:1281
PHP 16. i18n_taxonomy_field_attach_prepare_translation_alter() /var/www/html/site/includes/module.inc:1018
PHP 17. i18n_taxonomy_field_prepare_translation() /var/www/html/site/sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.module:321
PHP 18. i18n_taxonomy_term_get_translation() /var/www/html/site/sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.module:334
PHP 19. i18n_translation_set_load() /var/www/html/site/sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.module:439
PHP 20. entity_load() /var/www/html/site/sites/all/modules/i18n/i18n_translation/i18n_translation.module:272
PHP 21. DrupalDefaultEntityController->load() /var/www/html/site/includes/common.inc:7585
PHP 22. I18nTranslationSetController->attachLoad() /var/www/html/site/includes/entity.inc:204
PHP 23. i18n_translation_set_build() /var/www/html/site/sites/all/modules/i18n/i18n_translation/i18n_translation.module:28

jose reyero’s picture

Category: bug » support
Priority: Critical » Normal

Changing to support request, setting priority, until we find out whether this is actually a bug in i18n.

mropanen’s picture

I noticed that when i18n_translation_set_info calls i18n_object_info, the $info = module_invoke_all('i18n_object_info') line returns an empty array. For some reason the hooks are not being called.

EDIT: Starting to look like a caching thing... maybe $info = &drupal_static(__FUNCTION__) does something unexpected?

miiimooo’s picture

Category: support » bug
Status: Needs work » Active

Sorry for bumping this but has started happening here after a cache rebuild in various places

E.g. admin/structure/menu/manage/main-menu/translate

Fatal error: Call to a member function format_translation() on a non-object in /var/www/web142/web/drupal_files/modules/i18n/i18n_string/i18n_string.pages.inc on line 76 

admin/structure/menu/manage/translation

Fatal error: Class name must be a valid object or a string in /var/www/web142/web/drupal_files/modules/i18n/i18n_translation/i18n_translation.module on line 249 

Not quite sure where it may be coming from but it's running off empty caches so pretty sure it's not caching related.

Inserting a backtracer in i18n_translation_set_build I get this:

Array
(
    [0] => Array
        (
            [file] => /var/www/web142/web/drupal_files/modules/i18n/i18n_translation/i18n_translation.module
            [line] => 28
            [function] => i18n_translation_set_build
            [args] => Array
                (
                    [0] => menu_link
                    [1] => stdClass Object
                        (
                            [tsid] => 5
                            [title] => 
                            [type] => menu_link
                            [bundle] => 
                            [master_id] => 0
                            [status] => 0
                            [created] => 1328196530
                            [changed] => 1328196530
                        )

                )

        )

    [1] => Array
        (
            [file] => /var/www/drupal/drupal-7.12/includes/entity.inc
            [line] => 204
            [function] => attachLoad
            [class] => I18nTranslationSetController
            [object] => I18nTranslationSetController Object
                (
                    [entityCache:protected] => Array
                        (
                        )

                    [entityType:protected] => i18n_translation
                    [entityInfo:protected] => Array
                        (
                            [label] => Translation set
                            [controller class] => I18nTranslationSetController
                            [base table] => i18n_translation_set
                            [fieldable] => 
                            [entity keys] => Array
                                (
                                    [id] => tsid
                                    [bundle] => type
                                    [label] => title
                                    [revision] => 
                                )

                            [bundle keys] => Array
                                (
                                    [bundle] => type
                                )

                            [bundles] => Array
                                (
                                )

                            [static cache] => 1
                            [field cache] => 1
                            [load hook] => i18n_translation_load
                            [view modes] => Array
                                (
                                )

                            [translation] => Array
                                (
                                )

                            [schema_fields_sql] => Array
                                (
                                    [base table] => Array
                                        (
                                            [0] => tsid
                                            [1] => title
                                            [2] => type
                                            [3] => bundle
                                            [4] => master_id
                                            [5] => status
                                            [6] => created
                                            [7] => changed
                                        )

                                )

                            [apachesolr] => Array
                                (
                                    [indexable] => 
                                    [status callback] => 
                                    [document callback] => 
                                    [reindex callback] => 
                                )

                            [token type] => i18n_translation
                            [configuration] => 
                        )

                    [hookLoadArguments:protected] => Array
                        (
                        )

                    [idKey:protected] => tsid
                    [revisionKey:protected] => 
                    [revisionTable:protected] => 
                    [cache:protected] => 1
                )

            [type] => ->
            [args] => Array
                (
                    [0] => Array
                        (
                            [5] => stdClass Object
                                (
                                    [tsid] => 5
                                    [title] => 
                                    [type] => menu_link
                                    [bundle] => 
                                    [master_id] => 0
                                    [status] => 0
                                    [created] => 1328196530
                                    [changed] => 1328196530
                                )

                            [7] => stdClass Object
                                (
                                    [tsid] => 7
                                    [title] => 
                                    [type] => menu_link
                                    [bundle] => 
                                    [master_id] => 0
                                    [status] => 0
                                    [created] => 1328196662
                                    [changed] => 1328196662
                                )
[..]

                        )

                    [1] => 
                )

        )

    [2] => Array
        (
            [file] => /var/www/drupal/drupal-7.12/includes/common.inc
            [line] => 7585
            [function] => load
            [class] => DrupalDefaultEntityController
            [object] => I18nTranslationSetController Object
                (
                    [entityCache:protected] => Array
                        (
                        )

                    [entityType:protected] => i18n_translation
                    [entityInfo:protected] => Array
                        (
                            [label] => Translation set
                            [controller class] => I18nTranslationSetController
                            [base table] => i18n_translation_set
                            [fieldable] => 
                            [entity keys] => Array
                                (
                                    [id] => tsid
                                    [bundle] => type
                                    [label] => title
                                    [revision] => 
                                )

                            [bundle keys] => Array
                                (
                                    [bundle] => type
                                )

                            [bundles] => Array
                                (
                                )

                            [static cache] => 1
                            [field cache] => 1
                            [load hook] => i18n_translation_load
                            [view modes] => Array
                                (
                                )

                            [translation] => Array
                                (
                                )

                            [schema_fields_sql] => Array
                                (
                                    [base table] => Array
                                        (
                                            [0] => tsid
                                            [1] => title
                                            [2] => type
                                            [3] => bundle
                                            [4] => master_id
                                            [5] => status
                                            [6] => created
                                            [7] => changed
                                        )

                                )

                            [apachesolr] => Array
                                (
                                    [indexable] => 
                                    [status callback] => 
                                    [document callback] => 
                                    [reindex callback] => 
                                )

                            [token type] => i18n_translation
                            [configuration] => 
                        )

                    [hookLoadArguments:protected] => Array
                        (
                        )

                    [idKey:protected] => tsid
                    [revisionKey:protected] => 
                    [revisionTable:protected] => 
                    [cache:protected] => 1
                )

            [type] => ->
            [args] => Array
                (
                    [0] => Array
                        (
                            [0] => 24
                            [1] => 23
                            [2] => 22
                            [3] => 21
                            [4] => 20
                            [5] => 19
                            [6] => 18
                            [7] => 17
                            [8] => 16
                            [9] => 15
                            [10] => 10
                            [11] => 14
                            [12] => 13
                            [13] => 12
                            [14] => 11
                            [15] => 9
                            [16] => 8
                            [17] => 7
                            [18] => 5
                        )

                    [1] => Array
                        (
                        )

                )

        )

    [3] => Array
        (
            [file] => /var/www/web142/web/drupal_files/modules/i18n/i18n_translation/i18n_translation.admin.inc
            [line] => 39
            [function] => entity_load
            [args] => Array
                (
                    [0] => i18n_translation
                    [1] => Array
                        (
                            [0] => 24
                            [1] => 23
                            [2] => 22
                            [3] => 21
                            [4] => 20
                            [5] => 19
                            [6] => 18
                            [7] => 17
                            [8] => 16
                            [9] => 15
                            [10] => 10
                            [11] => 14
                            [12] => 13
                            [13] => 12
                            [14] => 11
                            [15] => 9
                            [16] => 8
                            [17] => 7
                            [18] => 5
                        )

                )

        )

    [4] => Array
        (
            [file] => /var/www/web142/web/drupal_files/modules/i18n/i18n_translation/i18n_translation.module
            [line] => 302
            [function] => i18n_translation_admin_overview
            [args] => Array
                (
                    [0] => menu_link
                )

        )

    [5] => Array
        (
            [function] => i18n_translation_set_list_manage
            [args] => Array
                (
                    [0] => menu_link
                )

        )

    [6] => Array
        (
            [file] => /var/www/drupal/drupal-7.12/includes/menu.inc
            [line] => 517
            [function] => call_user_func_array
            [args] => Array
                (
                    [0] => i18n_translation_set_list_manage
                    [1] => Array
                        (
                            [0] => menu_link
                        )

                )

        )

    [7] => Array
        (
            [file] => /var/www/drupal/drupal-7.12/index.php
            [line] => 21
            [function] => menu_execute_active_handler
            [args] => Array
                (
                )

        )

)

EDIT: shortened dump

miiimooo’s picture

I think it's got to do with i18n_object_info not returning the object info for menus. I've inserted this into i18n.module, line 351:

function i18n_object_info($type = NULL, $property = NULL, $default = NULL) {
  krumo::dump(module_implements('i18n_object_info'));

and it gives an empty array though I found
function i18n_menu_i18n_object_info() {
in i18n_menu/i18n_menu.i18n.inc

miiimooo’s picture

Priority: Normal » Major

I think this is a bug. I've inserted this:

function i18n_object_info($type = NULL, $property = NULL, $default = NULL) {
  module_load_include('i18n.inc', 'i18n_menu');

cleared cache_boostrap.module_implements and the PHP fatal errors have disappeared. Commenting out the module_load_include and flushing the cache the fatal errors are back.

guillaumev’s picture

Same issue here...

miiimooo’s picture

Now trying i18n_taxonomy and seems to get worse. Any ideas? I'm stuck but found this which seems related #1237266-1: Test with taxonomy translation + core menu + taxonomy menu.

miiimooo’s picture

@guillaumev: the site you're experiencing this, was it upgraded from D6 or is it a fresh D7 site?

miiimooo’s picture

Status: Active » Needs review

I think it has to do with the order the modules get called. On another site where everything works i18n gets called before 18n_string though they are both weight=10. On the broken site i18n_string gets called before i18n. Changing the module weight of i18n_string to 15 fixes the problem and all others here:

UPDATE `system` SET `weight` = '15' WHERE `name` = 'i18n_string';

Suggesting to change this in dev after review by module maintainer.

mgifford’s picture

Thanks @miimooo - that fixed it for me. I was getting that nasty WSOD from en/admin/structure/menu/item/2494/edit

EDIT - Wait.. It comes back when I clear the cache, so that's not it....

miiimooo’s picture

May be unrelated, it's definitely fixed here. Have you followed http://drupal.org/node/158043 ?

mgifford’s picture

Thanks for the WSOD reference. It's intermittent, but will definitely want to follow up on that if it persists.

jose reyero’s picture

Status: Needs review » Active

a) No patch for 'needs review' so changing status.

b) Some hooks have been reworked in latest -dev, try that version.

c) Changing module weights is not a solution unless we identify what is failing here.

miiimooo’s picture

Status: Active » Fixed

Thanks. I've checked the latest dev and works.

vacilando’s picture

I confirm that the problem of
PHP Fatal error: Call to a member function format_translation() on a non-object
does not exist any more in the latest dev.

nickgee’s picture

True, the DEV release doesn't bork.

Current translation sets seem to work too.

But all the sets are listed as undefined // unkown

Status: Fixed » Closed (fixed)

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