Loading data_custom/functions.bin +0 −0 File changed.Preview suppressed by a .gitattributes entry or the file's encoding is unsupported. View original file View changed file sources/database.php +22 −2 Original line number Diff line number Diff line Loading @@ -291,10 +291,30 @@ function db_supports_drop_table_if_exists($db) * Find whether full-text-search is present * * @param array $db A DB connection * @param ?string $table Table to check we have an index on (null: no check) * @param ?string $field Field to check we have an index on (null: no check) * @return boolean Whether it is */ function db_has_full_text($db) { function db_has_full_text($db, $table = null, $field = null) { if (($table !== null) && ($field !== null)) { $field = preg_replace('#^.*\.(.*)#', '$1', $field); $indexes = $GLOBALS['FORUM_DB']->query_select('db_meta_indices', array('i_fields', 'i_name'), array('i_table' => $table)); $okay = false; foreach ($indexes as $index) { if ($index['i_name'][0] == '#') { $fields = explode(',', $index['i_fields']); if (in_array($field, $fields)) { $okay = true; break; } } } if (!$okay) { return false; } } if ((is_array($db)) && (count($db) > 4)) { // Okay, we can't be lazy anymore $db = call_user_func_array(array($GLOBALS['DB_STATIC_OBJECT'], 'db_get_connection'), $db); _general_db_init(); Loading sources/filtercode.php +3 −1 Original line number Diff line number Diff line Loading @@ -828,6 +828,8 @@ function filtercode_to_sql($db, $filters, $content_type = null, $context = null, $db_fields = collapse_2d_complexity('m_name', 'm_type', $db->query_select('db_meta', array('m_name', 'm_type'), array('m_table' => $table))); $db_fields_for_table[$table] = $db_fields; } } else { $table = null; } foreach ($filters as $filter_i => $filter) { Loading Loading @@ -955,7 +957,7 @@ function filtercode_to_sql($db, $filters, $content_type = null, $context = null, case '~': require_code('database_search'); if ((db_has_full_text($GLOBALS['SITE_DB']->connection_read)) && (strlen($filter_val) > get_minimum_search_length())) { if ((db_has_full_text($GLOBALS['SITE_DB']->connection_read, $table, $filter_key)) && (strlen($filter_val) > get_minimum_search_length())) { if ($filter_val != '') { if ($alt != '') { $alt .= ' OR '; Loading sources/search.php +1 −1 Original line number Diff line number Diff line Loading @@ -527,7 +527,7 @@ function find_search_suggestions($request, $search_type = '') $q .= ' GROUP BY text_original'; } else { $q = 'SELECT ' . $cma_info['title_field'] . ' AS search FROM ' . get_table_prefix() . $cma_info['table']; if (db_has_full_text($GLOBALS['SITE_DB']->connection_read)) { if (db_has_full_text($GLOBALS['SITE_DB']->connection_read, $cma_info['table'], $cma_info['title_field'])) { $q .= ' WHERE ' . preg_replace('#\?#', $cma_info['title_field'], db_full_text_assemble(str_replace('?', '', $request), false)); } else { $q .= ' WHERE ' . $cma_info['title_field'] . ' LIKE \'' . db_encode_like($request . '%') . '\''; Loading Loading
data_custom/functions.bin +0 −0 File changed.Preview suppressed by a .gitattributes entry or the file's encoding is unsupported. View original file View changed file
sources/database.php +22 −2 Original line number Diff line number Diff line Loading @@ -291,10 +291,30 @@ function db_supports_drop_table_if_exists($db) * Find whether full-text-search is present * * @param array $db A DB connection * @param ?string $table Table to check we have an index on (null: no check) * @param ?string $field Field to check we have an index on (null: no check) * @return boolean Whether it is */ function db_has_full_text($db) { function db_has_full_text($db, $table = null, $field = null) { if (($table !== null) && ($field !== null)) { $field = preg_replace('#^.*\.(.*)#', '$1', $field); $indexes = $GLOBALS['FORUM_DB']->query_select('db_meta_indices', array('i_fields', 'i_name'), array('i_table' => $table)); $okay = false; foreach ($indexes as $index) { if ($index['i_name'][0] == '#') { $fields = explode(',', $index['i_fields']); if (in_array($field, $fields)) { $okay = true; break; } } } if (!$okay) { return false; } } if ((is_array($db)) && (count($db) > 4)) { // Okay, we can't be lazy anymore $db = call_user_func_array(array($GLOBALS['DB_STATIC_OBJECT'], 'db_get_connection'), $db); _general_db_init(); Loading
sources/filtercode.php +3 −1 Original line number Diff line number Diff line Loading @@ -828,6 +828,8 @@ function filtercode_to_sql($db, $filters, $content_type = null, $context = null, $db_fields = collapse_2d_complexity('m_name', 'm_type', $db->query_select('db_meta', array('m_name', 'm_type'), array('m_table' => $table))); $db_fields_for_table[$table] = $db_fields; } } else { $table = null; } foreach ($filters as $filter_i => $filter) { Loading Loading @@ -955,7 +957,7 @@ function filtercode_to_sql($db, $filters, $content_type = null, $context = null, case '~': require_code('database_search'); if ((db_has_full_text($GLOBALS['SITE_DB']->connection_read)) && (strlen($filter_val) > get_minimum_search_length())) { if ((db_has_full_text($GLOBALS['SITE_DB']->connection_read, $table, $filter_key)) && (strlen($filter_val) > get_minimum_search_length())) { if ($filter_val != '') { if ($alt != '') { $alt .= ' OR '; Loading
sources/search.php +1 −1 Original line number Diff line number Diff line Loading @@ -527,7 +527,7 @@ function find_search_suggestions($request, $search_type = '') $q .= ' GROUP BY text_original'; } else { $q = 'SELECT ' . $cma_info['title_field'] . ' AS search FROM ' . get_table_prefix() . $cma_info['table']; if (db_has_full_text($GLOBALS['SITE_DB']->connection_read)) { if (db_has_full_text($GLOBALS['SITE_DB']->connection_read, $cma_info['table'], $cma_info['title_field'])) { $q .= ' WHERE ' . preg_replace('#\?#', $cma_info['title_field'], db_full_text_assemble(str_replace('?', '', $request), false)); } else { $q .= ' WHERE ' . $cma_info['title_field'] . ' LIKE \'' . db_encode_like($request . '%') . '\''; Loading