I've just updated i18n to 7.1.3 and I now have a WSOD when I try to edit a node.

I tried to reproduce in a fresh new drupal 7 install :

  1. I create a vocabulary in my fresh default install
  2. I attach a "term reference" field to article content type
  3. I add a term "foo" to the new vocabulary
  4. I add an article "bar" and set the "foo" term to it
  5. I download and enable i18n and i18n_taxonomy
  6. Then I don't touch anything but I disable i18n_taxonomy
  7. I try to edit my article "bar" and I have a WSOD due to "Call to undefined function i18n_taxonomy_allowed_values()"

After that the only way I found to no longer have the WSOD is to remove the "term reference" field attached to the article content type.

I set priority to critical because if anyone have enabled i18n_taxonomy once and decided to disable it, it will break the site.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nikosnikos’s picture

In fact I think that there's two cases.

  • The first case is when I have i18n 7.x-1.3, I've enabled then disabled i18n_taxonomy -> WSOD on node edit
  • The second I had enabled a previous version of i18n_taxonomy and disabled it. I update i18n and then WSOD on node edit

The first case is due to i18n_taxonomy_disable, it uses field_update_field to update the field but field_update_field uses the prior field values for 'settings' (from where i18n_taxonomy_allowed_values is called) :

// In i18n_taxonomy.install
function i18n_taxonomy_disable() {
  foreach (field_info_fields() as $fieldname => $field) {
    if ($field['type'] == 'taxonomy_term_reference') {
      unset($field['settings']['options_list_callback']);
      field_update_field($field); // <------------ First part of the problem
    }
  }
}

// In field.crud.inc
function field_update_field($field) {
  // Check that the specified field exists.
  $prior_field = field_read_field($field['field_name']);
  // ...

  // Use the prior field values for anything not specifically set by the new
  // field to be sure that all values are set.
  $field += $prior_field;
  $field['settings'] += $prior_field['settings']; // <------ Second part of the problem

  // ...
}

The second case is due to i18n_taxonomy_update_7002 that add i18n_taxonomy_allowed_values callback to the taxonomy fields even if i18n_taxonomy module is disabled. It could be fixed with a condition like if (function_exists('i18n_taxonomy_allowed_values')) :

/**
 * Switch back to real taxonomy fields and override option_list_callback.
 */
function i18n_taxonomy_update_7002(&$sandbox) {
  // Update fields only if i18n_taxonomy is enabled.
  if (function_exists('i18n_taxonomy_allowed_values')) {

    foreach (field_info_fields() as $fieldname => $field) {
      if ($field['type'] == 'taxonomy_term_reference') {
        $field['module'] = 'taxonomy';
        $field['settings']['options_list_callback'] = 'i18n_taxonomy_allowed_values';
        field_update_field($field);
      }
    }
  }
}

nikosnikos’s picture

Status: Active » Needs review
FileSize
1.31 KB

Actually there's a simple patch to fix that.

If the patch work, if you have the WSOD and want to get your site back without i18n_taxonomy :

  1. apply the patch,
  2. enable i18n_taxonomy module,
  3. disable i18n_taxonomy module,
  4. if you won't need i18n_taxonomy you can uninstall it.
webflo’s picture

Assigned: Unassigned » webflo

Assigning to me for review.

webflo’s picture

webflo’s picture

Added a regression test.

Status: Needs review » Needs work

The last submitted patch, undefined-function-i18n_taxonomy_allowed_values-1410070-5.patch, failed testing.

webflo’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, undefined-function-i18n_taxonomy_allowed_values-1410070-5.patch, failed testing.

webflo’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, undefined-function-i18n_taxonomy_allowed_values-1410070-5.patch, failed testing.

webflo’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Needs work » Needs review
webflo’s picture

webflo’s picture

webflo’s picture

Status: Needs review » Fixed

Thanks! Commit 6c71e27 on 7.x-1.x

ytsurk’s picture

i disabled i18n on a website in BETA ..,
and added this if to fix the issue ..

/**
 * Implements hook_options_list().
 */
function taxonomy_options_list($field) {
  $function = !empty($field['settings']['options_list_callback']) ? $field['settings']['options_list_callback'] : 'taxonomy_allowed_values';

  if($function == 'i18n_taxonomy_allowed_values'){$function = 'taxonomy_allowed_values';}
  
  return $function($field);
}

how could i delete the field-setting from the DB without re-enabling and disabling he patched module ?

webflo’s picture

Download the latest i18n dev. Enable and disable i18n_taxonomy again. This should fix the issue. Your core hack is not right ...

nikosnikos’s picture

Cool ! The patch applied in dev fix the first case described in #1. But the committed patch don't fix the second case of that issue.

Test case :

  1. fresh standard install of drupal 7
  2. attach a "term reference" field to "article" content type in admin/structure/types/manage/article/fields
  3. add a new "article"
  4. drush dl i18n-7.x-1.2
  5. drush en i18n_taxonomy
  6. drush dis i18n_taxonomy
  7. drush dl i18n --dev
  8. drush updatedb
  9. edit the article created in 3 -> WSOD

Here's a possible patch on dev version.

ytsurk if i18n_taxonomy isn't uninstalled (just disabled), you can fix the issue by applying the patch to dev version of i18n and do an updatedb.

nikosnikos’s picture

Oops ! I forgot the patch... Here it is.

nikosnikos’s picture

Status: Fixed » Needs review

And I forgot to change the status too...

webflo’s picture

But hook_update_N() is called for active (enabled) modules only. Right?

nikosnikos’s picture

This is not clear in api documentation but in my test in #17
the update is applied on i18n_taxonomy when it is disabled but not uninstalled.

If I look in drupal core code, the update_get_update_list which is called by update.php perform the update on any installed schemas :

function update_get_update_list() {
  // Make sure that the system module is first in the list of updates.
  $ret = array('system' => array());

  $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
  foreach ($modules as $module => $schema_version) {

    // ...
  }
  // ...
}

So it seems to me that hook_update_N() is called if a module is installed, this module can be enabled or disabled there's no check on this.

ytsurk’s picture

agree .. ;)
just wondered if there would be some known rows to delete from the DB.

webflo’s picture

@ytsurk: this setting is serialized in {field_config}.data and {field_config_instance}.data

Jose Reyero’s picture

Priority: Critical » Major
Status: Needs review » Fixed

Committed the patch with some changes (reusing i18n_taxonomy_disable())

Status: Fixed » Closed (fixed)

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

BParticle’s picture

I tested the patches in this thread without success. I tried it on the development branch and the latest dev version, database update is not doing anything though. But I still get this WSOD. When I put error messages on in index.php it says:
Fatal error: Call to undefined function i18n_taxonomy_allowed_values() in /var/www/my-site/modules/taxonomy/taxonomy.module on line 1485

BParticle’s picture

Status: Closed (fixed) » Active
BParticle’s picture

I can't get my head around this one. This problem appears when reverting a features that has content types with multiple taxonomy terms. I tried to just remove all references to i18n, but the problem persists. Another clue I get from drush is the following: Creating default object from empty value entity.module:825
Never saw that before and I don't know if it is related, but it started showing when I got this blank screens problem.

Hope someone out there has a solution or something to go on!

BP

Status: Active » Needs review

Status: Needs review » Needs work
minorOffense’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
896 bytes

Update patch to apply to latest dev.

Kristen Pol’s picture

I tried to reproduce this issue with the instructions in the issue summary but had no luck. If someone has been able to reproduce this recently and the instructions are different from the issue summary, please update the issue summary with the correct steps. Thanks!

Kristen Pol’s picture

@minorOffense I'm not clear why you have your code in a hook_update_N function. This will get called if update.php (or drush updatedb) are called prior to the module being disabled as well, e.g.

  • module is enabled
  • patch is applied to module
  • update.php is run
  • hook_update_7005 is called
  • code in hook doesn't run because the function is available
  • module is disabled
  • code in hook_disable is run

Are you covering the case when hook_disable wasn't fired properly for some reason but the module is disabled? Thanks!

minorOffense’s picture

I was just fixing an early patch in comment https://www.drupal.org/node/1410070#comment-5503344 to work against the latest dev.

minorOffense’s picture

You're right though. The fix should detect a version of something or whether it ran at all.

Jose Reyero’s picture

Status: Needs review » Postponed (maintainer needs more info)

I don't think this issue exists anymore.

Maybe only for sites where i18n_taxonomy was disabled before the patches above were applied?
The easy workaround may be just enabling/disabling i18n_taxonomy again.

leistiko_texvet’s picture

I was getting this error and stumbled across this comment thread. #36 tipped me off to (what turned out to be) the easy-peasy solution (in my case).

Enable the "Translation" and "Taxonomy Translation" modules.

I hope this helps some people in the future.

jasonglisson’s picture

Applying the patch (#31) and turning on Taxonomy Translation worked for me.