The sequence of types generated by ckeditor_link_ckeditor_link_types() is critical and currently I think it's been done in a wrong way. For taxonomy it includes taxonomy before i18n_taxonomy and for menus it includes menu before i18n_menu.

This means that if the filter gets processed that taxonomy delivers a proper URL and i18n_taxonomy won't be checked anymore for that reason.

I suggest to switch the order or even just only include one of the both, i.e. the more specific one. A patch will follow in a minute.

Comments

jurgenhaas’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB
anrikun’s picture

Hi Jurgen! Can you provide a concrete example in order to reproduce the possible bug you describe?

jurgenhaas’s picture

@anrikun, here is our scenario:

  • Drupal 7.36
  • ... a lot of modules ...
  • i18n 7.x-1.12
  • ckeditor_link 7.x-2.3+5-dev

In a body field we have a link to /taxonomy/term/955 as an example. The filter gets processed and we end up in _ckeditor_link_filter_process($matches, $langcode = NULL) with a $langcode='de' in our case.

The following lines of code are now demonstrating the problem:

  $types = ckeditor_link_get_types();
  foreach ($types as $type) {
    $func = $type['module'] .'_ckeditor_link_'. $type['type'] .'_url';
    if (function_exists($func)) {
      $url = $func($path, $langcode);
      if ($url) {
        return 'href="'. $url;
      }
    }
  }

$types contains a few items and two of them are "taxonomy" and "i18n_taxonomy" in this order. That's why "taxonomy" gets tested first and there $url = $func($path, $langcode); returns a $url which points to the English version of the term although $langcode is German. This is no surprise, because "taxonomy" is not multilingual. But as it returns a value for $url, no further loops are taken, that result gets used and it is the wrong one.

If "i18n_taxonomy" were tested first, then this wouldn't have happened, because that returns the correct url for the given $langcode.

jurgenhaas’s picture

StatusFileSize
new1.02 KB

Re-rolled for drush make.