Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -8,6 +8,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
@ -105,6 +106,13 @@ function search_theme() {
];
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function search_theme_suggestions_search_result(array $variables) {
return ['search_result__' . $variables['plugin_id']];
}
/**
* Implements hook_preprocess_HOOK() for block templates.
*/
@ -218,7 +226,7 @@ function search_update_totals() {
// search_total. We use a LEFT JOIN between the two tables and keep only the
// rows which fail to join.
$result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL", [], ['target' => 'replica']);
$or = db_or();
$or = new Condition('OR');
foreach ($result as $word) {
$or->condition('word', $word->realword);
}
@ -257,7 +265,7 @@ function search_simplify($text, $langcode = NULL) {
$text = Html::decodeEntities($text);
// Lowercase
$text = Unicode::strtolower($text);
$text = mb_strtolower($text);
// Remove diacritics.
$text = \Drupal::service('transliteration')->removeDiacritics($text);
@ -322,7 +330,7 @@ function search_simplify($text, $langcode = NULL) {
function search_expand_cjk($matches) {
$min = \Drupal::config('search.settings')->get('index.minimum_word_size');
$str = $matches[0];
$length = Unicode::strlen($str);
$length = mb_strlen($str);
// If the text is shorter than the minimum word size, don't tokenize it.
if ($length <= $min) {
return ' ' . $str . ' ';
@ -332,7 +340,7 @@ function search_expand_cjk($matches) {
$chars = [];
for ($i = 0; $i < $length; $i++) {
// Add the next character off the beginning of the string to the queue.
$current = Unicode::substr($str, 0, 1);
$current = mb_substr($str, 0, 1);
$str = substr($str, strlen($current));
$chars[] = $current;
if ($i >= $min - 1) {
@ -445,20 +453,27 @@ function search_index($type, $sid, $langcode, $text) {
// Note: PHP ensures the array consists of alternating delimiters and literals
// and begins and ends with a literal (inserting $null as required).
$tag = FALSE; // Odd/even counter. Tag or no tag.
$score = 1; // Starting score per word
$accum = ' '; // Accumulator for cleaned up data
$tagstack = []; // Stack with open tags
$tagwords = 0; // Counter for consecutive words
$focus = 1; // Focus state
// Odd/even counter. Tag or no tag.
$tag = FALSE;
// Starting score per word.
$score = 1;
// Accumulator for cleaned up data.
$accum = ' ';
// Stack with open tags.
$tagstack = [];
// Counter for consecutive words.
$tagwords = 0;
// Focus state.
$focus = 1;
$scored_words = []; // Accumulator for words for index
// Accumulator for words for index.
$scored_words = [];
foreach ($split as $value) {
if ($tag) {
// Increase or decrease score per word based on tag
list($tagname) = explode(' ', $value, 2);
$tagname = Unicode::strtolower($tagname);
$tagname = mb_strtolower($tagname);
// Closing or opening tag?
if ($tagname[0] == '/') {
$tagname = substr($tagname, 1);
@ -495,8 +510,8 @@ function search_index($type, $sid, $langcode, $text) {
foreach ($words as $word) {
// Add word to accumulator
$accum .= $word . ' ';
// Check wordlength
if (is_numeric($word) || Unicode::strlen($word) >= $minimum_word_size) {
// Check word length.
if (is_numeric($word) || mb_strlen($word) >= $minimum_word_size) {
if (!isset($scored_words[$word])) {
$scored_words[$word] = 0;
}
@ -782,7 +797,7 @@ function search_excerpt($keys, $text, $langcode = NULL) {
$text = trim(preg_replace('/' . $preceded_by_boundary . '(?:' . implode('|', $keys) . ')' . $followed_by_boundary . '/iu', '<strong>\0</strong>', ' ' . $text . ' '));
return [
'#markup' => $text,
'#allowed_tags' => ['strong']
'#allowed_tags' => ['strong'],
];
}
@ -826,13 +841,13 @@ function _search_find_match_with_simplify($key, $text, $boundary, $langcode = NU
// See if there is a match after lower-casing and removing diacritics in
// both, which should preserve the string length.
$new_text = Unicode::strtolower($text);
$new_text = mb_strtolower($text);
$new_text = \Drupal::service('transliteration')->removeDiacritics($new_text);
$new_key = Unicode::strtolower($temp);
$new_key = mb_strtolower($temp);
$new_key = \Drupal::service('transliteration')->removeDiacritics($new_key);
if (preg_match('/' . $preceded_by_boundary . preg_quote($new_key, '/') . $followed_by_boundary . '/u', ' ' . $new_text . ' ')) {
$position = Unicode::strpos($new_text, $new_key);
return Unicode::substr($text, $position, Unicode::strlen($new_key));
$position = mb_strpos($new_text, $new_key);
return mb_substr($text, $position, mb_strlen($new_key));
}
// Run both text and key through search_simplify.
@ -861,7 +876,7 @@ function _search_find_match_with_simplify($key, $text, $boundary, $langcode = NU
$proposed_end_index = floor(($max_end_index + $min_end_index) / 2);
$proposed_end_pos = $words[$proposed_end_index][1];
// Since the split was done with preg_split(), the positions are byte counts
// not character counts, so use substr() not Unicode::substr() here.
// not character counts, so use substr() not mb_substr() here.
$trial_text = trim(search_simplify(substr($text, $start_pos, $proposed_end_pos - $start_pos), $langcode));
if (strpos($trial_text, $simplified_key) !== FALSE) {
// The proposed endpoint is fine, text still matches.
@ -887,7 +902,7 @@ function _search_find_match_with_simplify($key, $text, $boundary, $langcode = NU
$proposed_start_index = ceil(($max_start_index + $min_start_index) / 2);
$proposed_start_pos = $words[$proposed_start_index][1];
// Since the split was done with preg_split(), the positions are byte counts
// not character counts, so use substr() not Unicode::substr() here.
// not character counts, so use substr() not mb_substr() here.
$trial_text = trim(search_simplify(substr($text, $proposed_start_pos, $end_pos - $proposed_start_pos), $langcode));
if (strpos($trial_text, $simplified_key) !== FALSE) {
// The proposed start point is fine, text still matches.
@ -902,9 +917,8 @@ function _search_find_match_with_simplify($key, $text, $boundary, $langcode = NU
$start_index = $max_start_index;
// Return the matching text. We need to use substr() here and not the
// Unicode::substr() function, because the indices in $words came from
// preg_split(), so they are Unicode-safe byte positions, not character
// positions.
// mb_substr() function, because the indices in $words came from preg_split(),
// so they are Unicode-safe byte positions, not character positions.
return trim(substr($text, $words[$start_index][1], $words[$end_index][1] - $words[$start_index][1]));
}