updated search_api modules as indexation was not working localy

had to be tested in production
This commit is contained in:
Bachir Soussi Chiadmi
2017-05-24 18:57:04 +02:00
parent b5d76ec5e6
commit 28c7a0965a
53 changed files with 4166 additions and 187 deletions

View File

@@ -192,6 +192,12 @@ class SearchApiFacetapiAdapter extends FacetapiAdapter {
*/
public function getSearchKeys() {
$search = $this->getCurrentSearch();
// If the search is empty then there's no reason to continue.
if (!$search) {
return NULL;
}
$keys = $search[0]->getOriginalKeys();
if (is_array($keys)) {
// This will happen nearly never when displaying the search keys to the
@@ -281,10 +287,24 @@ class SearchApiFacetapiAdapter extends FacetapiAdapter {
// Date facets don't support the "OR" operator (for now).
$form['global']['operator']['#access'] = FALSE;
$default_value = FACETAPI_DATE_YEAR;
if (isset($options['date_granularity_min'])) {
$default_value = $options['date_granularity_min'];
}
$form['global']['date_granularity_min'] = array(
'#type' => 'select',
'#title' => t('Minimum granularity'),
'#description' => t('Determine the minimum drill-down level to start at'),
'#prefix' => '<div class="facetapi-global-setting">',
'#suffix' => '</div>',
'#options' => $granularity_options,
'#default_value' => $default_value,
);
}
// Add an "Exclude" option for terms.
if(!empty($facet['query types']) && in_array('term', $facet['query types'])) {
if (!empty($facet['query types']) && in_array('term', $facet['query types'])) {
$form['global']['operator']['#weight'] = -2;
unset($form['global']['operator']['#suffix']);
$form['global']['exclude'] = array(

View File

@@ -76,7 +76,7 @@ class SearchApiFacetapiDate extends SearchApiFacetapiTerm implements FacetapiQue
*/
protected function createRangeFilter($value) {
// Ignore any filters passed directly from the server (range or missing).
if (!$value || $value == '!' || (!ctype_digit($value[0]) && preg_match('/^[\[(][^ ]+ [^ ]+[])]$/', $value))) {
if (!$value || $value == '!' || (!ctype_digit($value[0]) && preg_match('/^[\[(][^ ]+ TO [^ ]+[\])]$/', $value))) {
return $value ? $value : NULL;
}
@@ -245,9 +245,19 @@ class SearchApiFacetapiDate extends SearchApiFacetapiTerm implements FacetapiQue
}
}
// Get the finest level of detail we're allowed to drill down to.
$settings = $facet->getSettings()->settings;
$max_granularity = isset($settings['date_granularity']) ? $settings['date_granularity'] : FACETAPI_DATE_MINUTE;
// Get the finest level of detail we're allowed to drill down to.
$max_granularity = FACETAPI_DATE_MINUTE;
if (isset($settings['date_granularity'])) {
$max_granularity = $settings['date_granularity'];
}
// Get the coarsest level of detail we're allowed to start at.
$min_granularity = FACETAPI_DATE_YEAR;
if (isset($settings['date_granularity_min'])) {
$min_granularity = $settings['date_granularity_min'];
}
// Gets active facets, starts building hierarchy.
$parent = $granularity = NULL;
@@ -301,11 +311,14 @@ class SearchApiFacetapiDate extends SearchApiFacetapiTerm implements FacetapiQue
FACETAPI_DATE_MINUTE => 2,
FACETAPI_DATE_SECOND => 1,
);
// Gets gap numbers for both the gap and minimum gap, checks if the gap
// is within the limit set by the $granularity parameter.
// Gets gap numbers for both the gap, minimum and maximum gap, checks if
// the gap is within the limit set by the $granularity parameters.
if ($gap_numbers[$granularity] < $gap_numbers[$max_granularity]) {
$granularity = $max_granularity;
}
if ($gap_numbers[$granularity] > $gap_numbers[$min_granularity]) {
$granularity = $min_granularity;
}
}
else {
$granularity = $max_granularity;

View File

@@ -9,9 +9,9 @@ files[] = plugins/facetapi/adapter.inc
files[] = plugins/facetapi/query_type_term.inc
files[] = plugins/facetapi/query_type_date.inc
; Information added by Drupal.org packaging script on 2016-07-21
version = "7.x-1.20"
; Information added by Drupal.org packaging script on 2017-02-23
version = "7.x-1.21"
core = "7.x"
project = "search_api"
datestamp = "1469117342"
datestamp = "1487844493"

View File

@@ -22,12 +22,14 @@ function search_api_facetapi_install() {
*/
function search_api_facetapi_uninstall() {
variable_del('search_api_facets_search_ids');
variable_del('date_format_search_api_facetapi_' . FACETAPI_DATE_YEAR);
variable_del('date_format_search_api_facetapi_' . FACETAPI_DATE_MONTH);
variable_del('date_format_search_api_facetapi_' . FACETAPI_DATE_DAY);
variable_del('date_format_search_api_facetapi_' . FACETAPI_DATE_HOUR);
variable_del('date_format_search_api_facetapi_' . FACETAPI_DATE_MINUTE);
variable_del('date_format_search_api_facetapi_' . FACETAPI_DATE_SECOND);
// We have to use the literal values here, as the Facet API module could have
// already been disabled at this point.
variable_del('date_format_search_api_facetapi_YEAR');
variable_del('date_format_search_api_facetapi_MONTH');
variable_del('date_format_search_api_facetapi_DAY');
variable_del('date_format_search_api_facetapi_HOUR');
variable_del('date_format_search_api_facetapi_MINUTE');
variable_del('date_format_search_api_facetapi_SECOND');
}
/**

View File

@@ -151,7 +151,7 @@ class SearchApiViewsFacetsBlockDisplay extends views_plugin_display_block {
}
}
public function query(){
public function query() {
parent::query();
$facet_field = $this->get_option('facet_field');
@@ -291,7 +291,7 @@ class SearchApiViewsFacetsBlockDisplay extends views_plugin_display_block {
);
}
public function execute(){
public function execute() {
$info['content'] = $this->render();
$info['content']['more'] = $this->render_more_link();
$info['subject'] = filter_xss_admin($this->view->get_title());

View File

@@ -119,7 +119,17 @@ class SearchApiViewsHandlerFilterFulltext extends SearchApiViewsHandlerFilterTex
}
$words = preg_split('/\s+/', $input);
$quoted = FALSE;
foreach ($words as $i => $word) {
// Protect quoted strings.
if ($quoted && $word[strlen($word) - 1] === '"') {
$quoted = FALSE;
continue;
}
if ($quoted || $word[0] === '"') {
$quoted = TRUE;
continue;
}
if (drupal_strlen($word) < $this->options['min_length']) {
unset($words[$i]);
}

View File

@@ -93,7 +93,7 @@ class SearchApiViewsHandlerFilterTaxonomyTerm extends SearchApiViewsHandlerFilte
$query->orderby('tv.name');
$query->orderby('td.weight');
$query->orderby('td.name');
$query->addTag('term_access');
$query->addTag('taxonomy_term_access');
if ($vocabulary) {
$query->condition('tv.machine_name', $vocabulary->machine_name);
}
@@ -272,7 +272,7 @@ class SearchApiViewsHandlerFilterTaxonomyTerm extends SearchApiViewsHandlerFilte
if (!empty($this->definition['vocabulary'])) {
$query->condition('tv.machine_name', $this->definition['vocabulary']);
}
$query->addTag('term_access');
$query->addTag('taxonomy_term_access');
$result = $query->execute();
foreach ($result as $term) {
unset($missing[strtolower($term->name)]);

View File

@@ -29,8 +29,10 @@ class SearchApiViewsHandlerFilterUser extends SearchApiViewsHandlerFilterEntity
protected function ids_to_strings(array $ids) {
$names = array();
$args[':uids'] = array_filter($ids);
$result = db_query("SELECT uid, name FROM {users} u WHERE uid IN (:uids)", $args);
$result = $result->fetchAllKeyed();
if ($args[':uids']) {
$result = db_query('SELECT uid, name FROM {users} u WHERE uid IN (:uids)', $args);
$result = $result->fetchAllKeyed();
}
foreach ($ids as $uid) {
if (!$uid) {
$names[] = variable_get('anonymous', t('Anonymous'));

View File

@@ -103,7 +103,7 @@ class SearchApiViewsCache extends views_plugin_cache_time {
$key_data['exposed_info'] = $_GET['exposed_info'];
}
}
$key = md5(serialize($key_data));
$key = drupal_hash_base64(serialize($key_data));
return $key;
}

View File

@@ -310,6 +310,9 @@ class SearchApiViewsQuery extends views_plugin_query {
if (!empty($this->view->override_path) && strpos(current_path(), $this->view->override_path) !== 0) {
$this->query->setOption('search_api_base_path', $this->view->override_path);
}
// Save query information for Views UI.
$view->build_info['query'] = (string) $this->query;
}
/**

View File

@@ -27,9 +27,9 @@ files[] = includes/handler_sort.inc
files[] = includes/plugin_cache.inc
files[] = includes/query.inc
; Information added by Drupal.org packaging script on 2016-07-21
version = "7.x-1.20"
; Information added by Drupal.org packaging script on 2017-02-23
version = "7.x-1.21"
core = "7.x"
project = "search_api"
datestamp = "1469117342"
datestamp = "1487844493"

View File

@@ -45,7 +45,10 @@ function search_api_views_search_api_index_update(SearchApiIndex $index) {
* Implements hook_search_api_index_delete().
*/
function search_api_views_search_api_index_delete(SearchApiIndex $index) {
_search_api_views_index_unavailable($index);
// Only do this if this is a "real" deletion, no revert.
if (!$index->hasStatus(ENTITY_IN_CODE)) {
_search_api_views_index_unavailable($index);
}
}
/**