Commit 33b050ca authored by catch's avatar catch
Browse files

Issue #3151364 by Charlie ChX Negyesi, amateescu, alexpott, jhodgdon:...

Issue #3151364 by Charlie ChX Negyesi, amateescu, alexpott, jhodgdon: diacritics are not removed from ǢǣǼǽǮǯ

(cherry picked from commit 920d1708)
parent 884d2a50
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -58,6 +58,21 @@ class PhpTransliteration implements TransliterationInterface {
   */
  protected $genericMap = [];

  /**
   * Special characters for ::removeDiacritics().
   *
   * Characters which have accented variants but their base character
   * transliterates to more than one ASCII character require special
   * treatment: we want to remove their accent and use the un-
   * transliterated base character.
   */
  protected $fixTransliterateForRemoveDiacritics = [
    'AE' => 'Æ',
    'ae' => 'æ',
    'ZH' => 'Ʒ',
    'zh' => 'ʒ',
  ];

  /**
   * Constructs a transliteration object.
   *
@@ -93,6 +108,9 @@ public function removeDiacritics($string) {
        if (strlen($to_add) === 1) {
          $replacement = $to_add;
        }
        elseif (isset($this->fixTransliterateForRemoveDiacritics[$to_add])) {
          $replacement = $this->fixTransliterateForRemoveDiacritics[$to_add];
        }
      }

      $result .= $replacement;
+11 −0
Original line number Diff line number Diff line
@@ -22,3 +22,14 @@ function search_post_update_block_page(&$sandbox = NULL) {
      return $block->getPluginId() === 'search_form_block';
    });
}

/**
 * Mark everything for reindexing after diacritics removal rule change.
 */
function search_post_update_reindex_after_diacritics_rule_change() {
  $search_page_repository = \Drupal::service('search.search_page_repository');
  foreach ($search_page_repository->getIndexableSearchPages() as $entity) {
    $entity->getPlugin()->markForReindex();
  }
  return t("Content has been marked for re-indexing for all active search pages. Searching will continue to work, but new content won't be indexed until all existing content has been re-indexed.");
}
+2 −2
Original line number Diff line number Diff line
@@ -58,8 +58,8 @@ public function providerTestPhpTransliterationRemoveDiacritics() {
      // Test all characters in the Unicode range 0x01CD to 0x024F.
      ['ǍǎǏ', 'AaI'],
      ['ǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟ', 'iOoUuUuUuUuUuǝAa'],
      ['ǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯ', 'AaǢǣGgGgKkOoOoǮǯ'],
      ['ǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿ', 'jDZDzdzGgǶǷNnAaǼǽOo'],
      ['ǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯ', 'AaÆæGgGgKkOoOoƷʒ'],
      ['ǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿ', 'jDZDzdzGgǶǷNnAaÆæOo'],
      ['ȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏ', 'AaAaEeEeIiIiOoOo'],
      ['ȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ', 'RrRrUuUuSsTtȜȝHh'],
      ['ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯ', 'ȠȡȢȣZzAaEeOoOoOo'],