Skip to content

Commit

Permalink
Revert Search API to v1.27.
Browse files Browse the repository at this point in the history
  • Loading branch information
revagomes committed Nov 8, 2021
1 parent fe685d2 commit ad25aad
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 165 deletions.
15 changes: 0 additions & 15 deletions profiles/pece/modules/contrib/search_api/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
Search API 1.x, dev (xxxx-xx-xx):
---------------------------------
- #3215213 by drunken monkey: Fixed undefined index "#value" in
SearchApiViewsHandlerFilterFulltext::exposed_validate().

Search API 1.28 (2021-07-19):
-----------------------------
- #3208036 by DamienMcKenna, Taran2L, drunken monkey: Fixed PHP 8.0
compatibility.
- #2159827 by mh86, drunken monkey, farse: Fixed wrong search base paths in
Facet API adapter.
- #3154538 by isholgueras, drunken monkey: Fixed exception handling in
datasource tracking methods.
- #2104623 by drunken monkey: Fixed facet filters for multi-valued date fields.

Search API 1.27 (2021-02-01):
-----------------------------
- #3178035 by mvc, drunken monkey: Fixed OR facets for non-numeric hierarchical
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ class SearchApiFacetapiAdapter extends FacetapiAdapter {
* Overrides FacetapiAdapter::getSearchPath().
*/
public function getSearchPath() {
return search_api_facetapi_current_search_path();
$search = $this->getCurrentSearch();
if ($search && $search[0]->getOption('search_api_base_path')) {
return $search[0]->getOption('search_api_base_path');
}
return $_GET['q'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SearchApiFacetapiDate extends SearchApiFacetapiTerm implements FacetapiQue
foreach($active_items as $active_item) {
$filter = $this->createRangeFilter($active_item['value']);
if ($filter) {
$this->addFacetFilter($date_query, $field, $filter, $query);
$this->addFacetFilter($date_query, $field, $filter);
}
}
$query->filter($date_query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SearchApiFacetapiTerm extends FacetapiQueryType implements FacetapiQueryTy

foreach ($active as $filter => $filter_array) {
$field = $this->facet['field'];
$this->addFacetFilter($facet_filter, $field, $filter, $query);
$this->addFacetFilter($facet_filter, $field, $filter);
}

// Now add the filter to the query.
Expand All @@ -104,16 +104,6 @@ class SearchApiFacetapiTerm extends FacetapiQueryType implements FacetapiQueryTy

/**
* Helper method for setting a facet filter on a query or query filter object.
*
* @param SearchApiQueryInterface|SearchApiQueryFilterInterface $query_filter
* The query or filter to which apply the filter.
* @param string $field
* The field to apply the filter to.
* @param string $filter
* The filter, in the internal string representation used by this module.
* @param SearchApiQuery|null $query
* (optional) If available, the search query object should be passed as the
* fourth parameter.
*/
protected function addFacetFilter($query_filter, $field, $filter) {
// Test if this filter should be negated.
Expand All @@ -128,26 +118,9 @@ class SearchApiFacetapiTerm extends FacetapiQueryType implements FacetapiQueryTy
elseif ($filter && $filter[0] == '[' && $filter[strlen($filter) - 1] == ']' && ($pos = strpos($filter, ' TO '))) {
$lower = trim(substr($filter, 1, $pos));
$upper = trim(substr($filter, $pos + 4, -1));
$supports_between = FALSE;
if (func_num_args() > 3) {
$query = func_get_arg(3);
if ($query instanceof SearchApiQuery) {
try {
$supports_between = $query->getIndex()->server()
->supportsFeature('search_api_between');
}
catch (SearchApiException $e) {
// Ignore, really not that important (and rather unlikely).
}
}
}
if ($lower == '*' && $upper == '*') {
$query_filter->condition($field, NULL, $exclude ? '=' : '<>');
}
elseif ($supports_between && $lower != '*' && $upper != '*') {
$operator = $exclude ? 'NOT BETWEEN' : 'BETWEEN';
$query_filter->condition($field, array($lower, $upper), $operator);
}
elseif (!$exclude) {
if ($lower != '*') {
// Iff we have a range with two finite boundaries, we set two
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ 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 2021-09-01
version = "7.x-1.x-dev"
; Information added by Drupal.org packaging script on 2021-02-01
version = "7.x-1.27"
core = "7.x"
project = "search_api"
datestamp = "1630475473"
datestamp = "1612192165"
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,10 @@ function search_api_facetapi_facetapi_facet_info(array $searcher_info) {
$field['key'] = $key;
// Determine which, if any, of the field type-specific options will be
// used for this field.
if (isset($field['entity_type'])) {
$type = $inner_type = $field['entity_type'];
}
else {
$type = $field['type'];
$inner_type = search_api_extract_inner_type($type);
}
$type_settings += array($inner_type => array());
$type = isset($field['entity_type']) ? $field['entity_type'] : $field['type'];
$type_settings += array($type => array());

$facet_info[$key] = $type_settings[$inner_type] + array(
$facet_info[$key] = $type_settings[$type] + array(
'label' => $field['name'],
'description' => t('Filter by @type.', array('@type' => $field['name'])),
'allowed operators' => array(
Expand All @@ -131,7 +125,7 @@ function search_api_facetapi_facetapi_facet_info(array $searcher_info) {
'map options' => array(),
'field type' => $type,
);
if ($inner_type === 'date') {
if ($type === 'date') {
$facet_info[$key]['description'] .= ' ' . t('(Caution: This may perform very poorly for large result sets.)');
}
$facet_info[$key]['map options'] += array(
Expand Down Expand Up @@ -209,7 +203,6 @@ function search_api_facetapi_search_api_query_alter($query) {
if ($index->server()->supportsFeature('search_api_facets')) {
// This is the main point of communication between the facet system and the
// search back-end - it makes the query respond to active facets.
search_api_facetapi_current_search_path($query);
$searcher = 'search_api@' . $index->machine_name;
$adapter = facetapi_adapter_load($searcher);
if ($adapter) {
Expand Down Expand Up @@ -270,29 +263,6 @@ function search_api_facetapi_date_format_types() {
);
}

/**
* Helper function that statically stores the Search API's base path. Can
* either be used to store or retrieve the base path.
*
* This static store is used in SearchApiFacetapiAdapter::getSearchPath() in
* order to retrieve the current search base path. Just relying on
* search_api_current_search() to retrieve the current query is not enough, as
* the path might be requested before the query is finally executed and stored.
*
* @param SearchApiQueryInterface $query
* When storing the base base, the query that is executed. Else NULL.
*
* @return
* The Search API's base path.
*/
function search_api_facetapi_current_search_path(SearchApiQueryInterface $query = NULL) {
$path = &drupal_static(__FUNCTION__, '');
if ($query && $query->getOption('search_api_base_path')) {
$path = $query->getOption('search_api_base_path');
}
return $path;
}

/**
* Menu callback for the facet settings page.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class SearchApiViewsHandlerFilterFulltext extends SearchApiViewsHandlerFilterTex
}

// Don't validate on form reset.
if (!empty($form_state['triggering_element']['#value'])
&& !empty($form['reset']['#value'])
if (!empty($form_state['triggering_element'])
&& !empty($form['reset'])
&& $form_state['triggering_element']['#value'] === $form['reset']['#value']) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,11 @@ class SearchApiViewsQuery extends views_plugin_query {
$this->query->setOption('search_api_bypass_access', TRUE);
}

// Store the Views base path.
$this->query->setOption('search_api_base_path', $this->view->get_path());
// If the View and the Panel conspire to provide an overridden path then
// pass that through as the base path.
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ files[] = includes/plugin_cache.inc
files[] = includes/plugin_content_cache.inc
files[] = includes/query.inc

; Information added by Drupal.org packaging script on 2021-09-01
version = "7.x-1.x-dev"
; Information added by Drupal.org packaging script on 2021-02-01
version = "7.x-1.27"
core = "7.x"
project = "search_api"
datestamp = "1630475473"
datestamp = "1612192165"
77 changes: 12 additions & 65 deletions profiles/pece/modules/contrib/search_api/includes/datasource.inc
Original file line number Diff line number Diff line change
Expand Up @@ -628,22 +628,7 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
));
}
}
try {
$insert->execute();
}
catch (Exception $e) {
$tmp = array_slice($item_ids, 0, 10);
$item_ids_string = '"' . implode('", "', $tmp) . '"';
$index_names = array();
foreach ($indexes as $index) {
$index_names[] = $index->name;
}
$vars = array(
'%indexes' => implode(', ', $index_names),
'@item_ids' => $item_ids_string,
);
watchdog_exception('search_api', $e, '%type while tracking item inserts (IDs: @item_ids) on index(es) %indexes: !message in %function (line %line of %file).', $vars);
}
$insert->execute();
}
}

Expand All @@ -667,24 +652,8 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
if ($item_ids !== FALSE) {
$update->condition($this->itemIdColumn, $item_ids, 'IN');
}
try {
$update->execute();
$indexes_by_id[$index->id] = $index;
}
catch (Exception $e) {
if ($item_ids === FALSE) {
$item_ids_string = t('all');
}
else {
$tmp = array_slice($item_ids, 0, 10);
$item_ids_string = '"' . implode('", "', $tmp) . '"';
}
$vars = array(
'%index' => $index->name,
'@item_ids' => $item_ids_string,
);
watchdog_exception('search_api', $e, '%type while tracking item updates (IDs: @item_ids) on index %index: !message in %function (line %line of %file).', $vars);
}
$update->execute();
$indexes_by_id[$index->id] = $index;
}

// Determine and return the indexes with any changed items. If $item_ids is
Expand Down Expand Up @@ -732,24 +701,13 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
return;
}
$this->checkIndex($index);
try {
db_update($this->table)
->fields(array(
$this->changedColumn => 0,
))
->condition($this->itemIdColumn, $item_ids, 'IN')
->condition($this->indexIdColumn, $index->id)
->execute();
}
catch (Exception $e) {
$tmp = array_slice($item_ids, 0, 10);
$item_ids_string = '"' . implode('", "', $tmp) . '"';
$vars = array(
'%index' => $index->name,
'@item_ids' => $item_ids_string,
);
watchdog_exception('search_api', $e, '%type while tracking indexed items (IDs: @item_ids) on index %index: !message in %function (line %line of %file).', $vars);
}
db_update($this->table)
->fields(array(
$this->changedColumn => 0,
))
->condition($this->itemIdColumn, $item_ids, 'IN')
->condition($this->indexIdColumn, $index->id)
->execute();
}

/**
Expand All @@ -767,19 +725,8 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
$delete = db_delete($this->table)
->condition($this->indexIdColumn, $index->id)
->condition($this->itemIdColumn, $item_ids, 'IN');
try {
if ($delete->execute()) {
$ret[] = $index;
}
}
catch (Exception $e) {
$tmp = array_slice($item_ids, 0, 10);
$item_ids_string = '"' . implode('", "', $tmp) . '"';
$vars = array(
'%index' => $index->name,
'@item_ids' => $item_ids_string,
);
watchdog_exception('search_api', $e, '%type while tracking deleted items (IDs: @item_ids) on index %index: !message in %function (line %line of %file).', $vars);
if ($delete->execute()) {
$ret[] = $index;
}
}

Expand Down
6 changes: 3 additions & 3 deletions profiles/pece/modules/contrib/search_api/search_api.info
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ files[] = includes/service.inc

configure = admin/config/search/search_api

; Information added by Drupal.org packaging script on 2021-09-01
version = "7.x-1.x-dev"
; Information added by Drupal.org packaging script on 2021-02-01
version = "7.x-1.27"
core = "7.x"
project = "search_api"
datestamp = "1630475473"
datestamp = "1612192165"
2 changes: 1 addition & 1 deletion profiles/pece/modules/contrib/search_api/search_api.module
Original file line number Diff line number Diff line change
Expand Up @@ -3401,7 +3401,7 @@ function _search_api_batch_indexing_create(SearchApiIndex $index, $batch_size, $
* @param $context
* An array (or object implementing ArrayAccess) containing the batch context.
*/
function _search_api_batch_indexing_callback(SearchApiIndex $index, $batch_size, $limit, $drush, &$context) {
function _search_api_batch_indexing_callback(SearchApiIndex $index, $batch_size, $limit, $drush = FALSE, &$context) {
// Persistent data among batch runs.
if (!isset($context['sandbox']['limit'])) {
$context['sandbox']['limit'] = $limit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ files[] = search_api_test.module

hidden = TRUE

; Information added by Drupal.org packaging script on 2021-09-01
version = "7.x-1.x-dev"
; Information added by Drupal.org packaging script on 2021-02-01
version = "7.x-1.27"
core = "7.x"
project = "search_api"
datestamp = "1630475473"
datestamp = "1612192165"
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ files[] = search_api_test_service_2.module

hidden = TRUE

; Information added by Drupal.org packaging script on 2021-09-01
version = "7.x-1.x-dev"
; Information added by Drupal.org packaging script on 2021-02-01
version = "7.x-1.27"
core = "7.x"
project = "search_api"
datestamp = "1630475473"
datestamp = "1612192165"
2 changes: 1 addition & 1 deletion profiles/pece/pece.make
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ projects[color_field][version] = 1.8
; Search API
; Overrides panopoly's search_api settings.
projects[search_api][subdir] = contrib
projects[search_api][version] = 1.x
projects[search_api][version] = 1.27
projects[search_api][patch][] = ./patches/search_api_fix-composer-friendly-dependencies-issue.patch

; Search API DB
Expand Down

0 comments on commit ad25aad

Please sign in to comment.