summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandy2018-02-18 22:34:23 (GMT)
committerThomas Seidl2018-02-18 22:34:23 (GMT)
commiteb15a801158acfc74bebfcfbac1fe60dd3bf81a8 (patch)
tree442b27e9d15dbeaabf78239766c782fcc4901cad
parent9fa46446762b4f35b1514174542b3f88e372685f (diff)
Issue #1903004 by AndyF, joseph.olstad, drunken monkey: Fixed errors at feature module installation in certain edge cases.
-rw-r--r--CHANGELOG.txt2
-rw-r--r--search_api.module22
-rw-r--r--search_api.test9
-rw-r--r--tests/search_api_test_2.info10
-rw-r--r--tests/search_api_test_2.module136
5 files changed, 177 insertions, 2 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 9ad4ce3..f637b34 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,5 +1,7 @@
Search API 1.x, dev (xxxx-xx-xx):
---------------------------------
+- #1903004 by AndyF, joseph.olstad, drunken monkey: Fixed errors at feature
+ module installation in certain edge cases.
- #2889989 by kevineinarsson, drunken monkey, kristofferwiklund: Fixed
highlighting for text with multi-byte characters.
- #1393064 by xlyz, drunken monkey, jannis: Fixed handling of empty facet
diff --git a/search_api.module b/search_api.module
index 98760ab..53d00bd 100644
--- a/search_api.module
+++ b/search_api.module
@@ -1026,6 +1026,28 @@ function search_api_search_api_item_type_info() {
}
/**
+ * Implements hook_module_implements_alter().
+ *
+ * Ensures the item type and service class static caches are invalidated at the
+ * right time.
+ */
+function search_api_module_implements_alter(array &$implementations, $hook) {
+ switch ($hook) {
+ case 'modules_enabled':
+ $group = $implementations['search_api'];
+ unset($implementations['search_api']);
+ $implementations = array('search_api' => $group) + $implementations;
+ break;
+
+ case 'modules_disabled':
+ $group = $implementations['search_api'];
+ unset($implementations['search_api']);
+ $implementations['search_api'] = $group;
+ break;
+ }
+}
+
+/**
* Implements hook_modules_enabled().
*/
function search_api_modules_enabled() {
diff --git a/search_api.test b/search_api.test
index 23f36bc..76a8970 100644
--- a/search_api.test
+++ b/search_api.test
@@ -86,6 +86,7 @@ class SearchApiWebTest extends DrupalWebTestCase {
* and then run tests on it.
*/
public function testFramework() {
+ module_enable(array('search_api_test_2'));
$this->drupalLogin($this->drupalCreateUser(array('administer search_api')));
$this->insertItems();
$this->createIndex();
@@ -730,13 +731,17 @@ class SearchApiWebTest extends DrupalWebTestCase {
* deleteServer()) and that all associated tables and variables are removed.
*/
protected function disableModules() {
+ module_disable(array('search_api_test_2'), FALSE);
+ $this->assertFalse(module_exists('search_api_test_2'), 'Second test module was successfully disabled.');
module_disable(array('search_api_test'), FALSE);
- $this->assertFalse(module_exists('search_api_test'), 'Test module was successfully disabled.');
+ $this->assertFalse(module_exists('search_api_test'), 'First test module was successfully disabled.');
module_disable(array('search_api'), FALSE);
$this->assertFalse(module_exists('search_api'), 'Search API module was successfully disabled.');
+ drupal_uninstall_modules(array('search_api_test_2'), FALSE);
+ $this->assertEqual(drupal_get_installed_schema_version('search_api_test_2', TRUE), SCHEMA_UNINSTALLED, 'Second test module was successfully uninstalled.');
drupal_uninstall_modules(array('search_api_test'), FALSE);
- $this->assertEqual(drupal_get_installed_schema_version('search_api_test', TRUE), SCHEMA_UNINSTALLED, 'Test module was successfully uninstalled.');
+ $this->assertEqual(drupal_get_installed_schema_version('search_api_test', TRUE), SCHEMA_UNINSTALLED, 'First test module was successfully uninstalled.');
$this->assertFalse(db_table_exists('search_api_test'), 'Test module table was successfully removed.');
drupal_uninstall_modules(array('search_api'), FALSE);
$this->assertEqual(drupal_get_installed_schema_version('search_api', TRUE), SCHEMA_UNINSTALLED, 'Search API module was successfully uninstalled.');
diff --git a/tests/search_api_test_2.info b/tests/search_api_test_2.info
new file mode 100644
index 0000000..a3beff1
--- /dev/null
+++ b/tests/search_api_test_2.info
@@ -0,0 +1,10 @@
+name = Search API test service 2
+description = "A module providing a second test search service."
+core = 7.x
+package = Search
+
+dependencies[] = search_api
+
+files[] = search_api_test_service_2.module
+
+hidden = TRUE
diff --git a/tests/search_api_test_2.module b/tests/search_api_test_2.module
new file mode 100644
index 0000000..d78a80e
--- /dev/null
+++ b/tests/search_api_test_2.module
@@ -0,0 +1,136 @@
+<?php
+
+/**
+ * @file
+ * Provides a second test service and server for testing Search API.
+ */
+
+/**
+ * Implements hook_search_api_service_info().
+ */
+function search_api_test_2_search_api_service_info() {
+ $name = 'search_api_test_service_2';
+ $services[$name] = array(
+ 'name' => $name,
+ 'description' => 'search_api_test_service_2 description',
+ 'class' => 'SearchApiDummyService',
+ );
+ return $services;
+}
+
+/**
+ * Implements hook_default_search_api_server().
+ */
+function search_api_test_2_default_search_api_server() {
+ $id = 'test_server_2';
+ $items[$id] = entity_create('search_api_server', array(
+ 'name' => 'Search API test server 2',
+ 'machine_name' => $id,
+ 'enabled' => 1,
+ 'description' => 'A server used for testing.',
+ 'class' => 'search_api_test_service_2',
+ ));
+ return $items;
+}
+
+/**
+ * Dummy service for testing.
+ */
+class SearchApiDummyService implements SearchApiServiceInterface {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function __construct(\SearchApiServer $server) {}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function configurationForm(array $form, array &$form_state) {
+ return array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function configurationFormValidate(array $form, array &$values, array &$form_state) {}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function configurationFormSubmit(array $form, array &$values, array &$form_state) {}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function supportsFeature($feature) {
+ return FALSE;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function viewSettings() {
+ return array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function postCreate() {}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function postUpdate() {
+ return FALSE;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function preDelete() {}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function addIndex(SearchApiIndex $index) {}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function fieldsUpdated(SearchApiIndex $index) {
+ return FALSE;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function removeIndex($index) {}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function indexItems(SearchApiIndex $index, array $items) {
+ return array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function deleteItems($ids = 'all', SearchApiIndex $index = NULL) {}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function query(SearchApiIndex $index, $options = array()) {
+ throw new SearchApiException("The dummy service doesn't support queries");
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function search(SearchApiQueryInterface $query) {
+ return array();
+ }
+}