Commit 8413de15 authored by japerry's avatar japerry
Browse files

Update Search v3 classes to be consistent with v2 for more seamless update path.

parent 8a05bdd5
......@@ -52,7 +52,7 @@ Hidden settings
- acquia_search.settings.extract_query_handler_option
String that contains the extract query handler option. Default value is
"update/extract"'.
See SearchApiSolrAcquiaSearchConnector::getExtractQuery() for details.
See SearchApiSolrSearchApiSolrAcquiaConnector::getExtractQuery() for details.
Here's an example for settings.php:
......
......@@ -7,7 +7,7 @@
use Drupal\acquia_search\Helper\Messages;
use Drupal\acquia_search\Helper\Runtime;
use Drupal\acquia_search\Plugin\SolrConnector\AcquiaSearchConnector;
use Drupal\acquia_search\Plugin\SolrConnector\SearchApiSolrAcquiaConnector;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormState;
use Drupal\search_api\Entity\Server;
......@@ -56,7 +56,7 @@ function acquia_search_search_api_server_load(array $entities) {
unset($backend_config['overridden_by_acquia_search']);
if (Runtime::shouldEnforceReadOnlyMode()) {
$backend_config['overridden_by_acquia_search'] = AcquiaSearchConnector::READ_ONLY;
$backend_config['overridden_by_acquia_search'] = SearchApiSolrAcquiaConnector::READ_ONLY;
}
$server->setBackendConfig($backend_config);
......@@ -102,7 +102,7 @@ function acquia_search_search_api_index_load($entities) {
// Set this index to read-only mode.
$index->set('read_only', TRUE);
// Flag this index as having been altered by this module.
$index->setOption('overridden_by_acquia_search', AcquiaSearchConnector::READ_ONLY);
$index->setOption('overridden_by_acquia_search', SearchApiSolrAcquiaConnector::READ_ONLY);
}
}
}
......
......@@ -5,6 +5,7 @@
* Search Solr updates once other modules have made their own updates.
*/
use Drupal\acquia_search\Helper\Storage;
use Drupal\Core\PhpStorage\PhpStorageFactory;
/**
......@@ -16,21 +17,18 @@ function acquia_search_post_update_clear_routes() {
}
/**
* Remove Acquia Search 2.x config.
* Upgrade from Acquia Search v2 to v3.
*/
function aacquia_search_post_update_move_search_modules() {
function acquia_search_post_update_move_search_modules() {
$config_factory = \Drupal::configFactory();
$config_to_delete = [
'block.block.exposedformacquia_searchpage',
'search_api.index.acquia_search_index',
'search_api.server.acquia_search_server',
'views.view.acquia_search',
];
foreach ($config_to_delete as $config_name) {
if ($config = $config_factory->getEditable($config_name)) {
$config->delete();
}
\Drupal::service('config.installer')->installDefaultConfig('module', 'acquia_search');
// Remove exposed block if its still around
if ($config = $config_factory->getEditable('block.block.exposedformacquia_searchpage')) {
$config->delete();
}
// Uninstall Search API Solr Multilingual if its still around.
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = \Drupal::service('module_installer');
if (\Drupal::moduleHandler()->moduleExists('search_api_solr_multilingual')) {
......@@ -48,4 +46,16 @@ function aacquia_search_post_update_move_search_modules() {
->get('acquia_connector.identifier'));
$storage->setUuid($subscription['uuid']);
}
if ($search_config = $config_factory->getEditable('acquia_search.settings')) {
if ($override = $search_config->get('default_search_core')) {
$search_config->set('override_search_core', $override);
$search_config->clear('default_search_core');
$search_config->save();
}
if ($override_settings = $search_config->get('default_search_core')) {
\Drupal::messenger()->addWarning(t(
"'acquia_connector.settings.default_search_core' is being overridden by settings.php. Update the key to acquia_connector.settings.override_search_core to continue overridding the core (usually for local development)"));
}
}
}
services:
acquia_search.search_subscriber:
class: Drupal\acquia_search\EventSubscriber\AcquiaSearchSubscriber
class: Drupal\acquia_search\EventSubscriber\SearchSubscriber
tags:
- { name: 'event_subscriber' }
......@@ -10,7 +10,7 @@
},
"conflict": {
"drupal/search_api_solr_multilingual": "<3",
"drupal/acquia_connector": "^1"
"drupal/acquia_connector": "<3"
},
"require-dev": {
"drush/drush": "^10.0"
......
......@@ -7,12 +7,12 @@ dependencies:
module:
- acquia_search
- search_api_solr
id: acquia_search_search_api_solr_server
name: 'Acquia Search Solr Search API Solr server'
id: acquia_search_server
name: 'Acquia Search API Solr server'
description: ''
backend: search_api_solr
backend_config:
connector: solr_acquia_search
connector: solr_acquia_connector
connector_config:
scheme: https
timeout: '10'
......
......@@ -7,7 +7,7 @@ dependencies:
- node
config:
- field.storage.node.body
- search_api.server.acquia_search_search_api_solr_server
- search_api.server.acquia_search_server
third_party_settings:
search_api_solr:
finalize: false
......@@ -30,8 +30,8 @@ third_party_settings:
fragsize: 0
advanced:
index_prefix: ''
id: acquia_search_search_api_solr_index
name: 'Acquia Search Solr Search API Solr index'
id: acquia_search_index
name: 'Acquia Search Solr Index'
description: ''
read_only: false
field_settings:
......@@ -146,4 +146,4 @@ tracker_settings:
options:
index_directly: false
cron_limit: 50
server: acquia_search_search_api_solr_server
server: acquia_search_server
......@@ -3,7 +3,7 @@ status: true
dependencies:
config:
- field.storage.node.body
- search_api.index.acquia_search_search_api_solr_index
- search_api.index.acquia_search_index
- system.menu.main
module:
- search_api
......@@ -14,7 +14,7 @@ label: 'Acquia Search Solr'
module: views
description: ''
tag: ''
base_table: search_api_index_acquia_search_search_api_solr_index
base_table: search_api_index_acquia_search_index
base_field: search_api_id
core: 8.x
display:
......@@ -87,7 +87,7 @@ display:
fields:
title:
id: title
table: search_api_index_acquia_search_search_api_solr_index
table: search_api_index_acquia_search_index
field: title
relationship: none
group_type: group
......@@ -157,7 +157,7 @@ display:
plugin_id: search_api_field
body:
id: body
table: search_api_index_acquia_search_search_api_solr_index
table: search_api_index_acquia_search_index
field: body
relationship: none
group_type: group
......@@ -226,7 +226,7 @@ display:
plugin_id: search_api_field
search_api_excerpt:
id: search_api_excerpt
table: search_api_index_acquia_search_search_api_solr_index
table: search_api_index_acquia_search_index
field: search_api_excerpt
relationship: none
group_type: group
......@@ -279,7 +279,7 @@ display:
plugin_id: search_api
type:
id: type
table: search_api_index_acquia_search_search_api_solr_index
table: search_api_index_acquia_search_index
field: type
relationship: none
group_type: group
......@@ -353,7 +353,7 @@ display:
filters:
search_api_fulltext:
id: search_api_fulltext
table: search_api_index_acquia_search_search_api_solr_index
table: search_api_index_acquia_search_index
field: search_api_fulltext
relationship: none
group_type: group
......@@ -396,7 +396,7 @@ display:
sorts:
search_api_relevance:
id: search_api_relevance
table: search_api_index_acquia_search_search_api_solr_index
table: search_api_index_acquia_search_index
field: search_api_relevance
relationship: none
group_type: group
......
......@@ -17,13 +17,13 @@ use Solarium\Exception\HttpException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class AcquiaSearchSubscriber.
* Class SearchSubscriber.
*
* Extends Solarium plugin for the Acquia Search module: authenticate, etc.
*
* @package Drupal\acquia_search\EventSubscriber
*/
class AcquiaSearchSubscriber extends AbstractPlugin implements EventSubscriberInterface {
class SearchSubscriber extends AbstractPlugin implements EventSubscriberInterface {
/**
* {@inheritdoc}
......
......@@ -2,7 +2,7 @@
namespace Drupal\acquia_search\Helper;
use Drupal\acquia_search\Plugin\SolrConnector\AcquiaSearchConnector;
use Drupal\acquia_search\Plugin\SolrConnector\SearchApiSolrAcquiaConnector;
use Drupal\Core\Render\Markup;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\search_api\Entity\Server;
......@@ -142,10 +142,10 @@ class Messages {
public static function getOverriddenModeMessage(int $override) {
switch ($override) {
case AcquiaSearchConnector::READ_ONLY:
case SearchApiSolrAcquiaConnector::READ_ONLY:
return ['#markup' => '<span class="color-warning">' . t('Acquia Search Solr module automatically enforced read-only mode on this connection.') . '</span>'];
case AcquiaSearchConnector::OVERRIDE_AUTO_SET:
case SearchApiSolrAcquiaConnector::OVERRIDE_AUTO_SET:
return t('Acquia Search Solr module automatically selected the proper Solr connection based on the detected environment and configuration.');
}
......
......@@ -152,7 +152,7 @@ class Runtime {
$backend_config = $server->getBackendConfig();
return !empty($backend_config['connector']) && $backend_config['connector'] === 'solr_acquia_search';
return !empty($backend_config['connector']) && $backend_config['connector'] === 'solr_acquia_connector';
}
......
......@@ -91,7 +91,7 @@ class Storage {
* @return string
* Extract query handler option.
*
* @see \Drupal\acquia_search\Plugin\SolrConnector\AcquiaSearchConnector::getExtractQuery()
* @see \Drupal\acquia_search\Plugin\SolrConnector\SearchApiSolrAcquiaConnector::getExtractQuery()
*/
public static function getExtractQueryHandlerOption(): string {
......
......@@ -17,19 +17,19 @@ use Solarium\Exception\UnexpectedValueException;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class AcquiaSearchConnector.
* Class SearchApiSolrAcquiaConnector.
*
* Extends SolrConnectorPluginBase for Acquia Search Solr.
*
* @package Drupal\acquia_search\Plugin\SolrConnector
*
* @SolrConnector(
* id = "solr_acquia_search",
* id = "solr_acquia_connector",
* label = @Translation("Acquia"),
* description = @Translation("Index items using an Acquia Apache Solr search server.")
* )
*/
class AcquiaSearchConnector extends SolrConnectorPluginBase {
class SearchApiSolrAcquiaConnector extends SolrConnectorPluginBase {
/**
* Automatically selected the proper Solr connection based on the environment.
......@@ -56,7 +56,7 @@ class AcquiaSearchConnector extends SolrConnectorPluginBase {
/**
* Event subscriber.
*
* @var \Drupal\acquia_search\EventSubscriber\AcquiaSearchSubscriber
* @var \Drupal\acquia_search\EventSubscriber\SearchSubscriber
*/
protected $searchSubscriber;
......@@ -132,7 +132,7 @@ class AcquiaSearchConnector extends SolrConnectorPluginBase {
$configuration['host'] = $preferred_core_service->getPreferredCoreHostname();
$configuration['core'] = $preferred_core_service->getPreferredCoreId();
$configuration['key'] = self::ENDPOINT_KEY;
$configuration['overridden_by_acquia_search'] = AcquiaSearchConnector::OVERRIDE_AUTO_SET;
$configuration['overridden_by_acquia_search'] = SearchApiSolrAcquiaConnector::OVERRIDE_AUTO_SET;
return $configuration;
......@@ -173,7 +173,7 @@ class AcquiaSearchConnector extends SolrConnectorPluginBase {
*/
protected function setReadOnlyMode(array $configuration): array {
$configuration['overridden_by_acquia_search'] = AcquiaSearchConnector::READ_ONLY;
$configuration['overridden_by_acquia_search'] = SearchApiSolrAcquiaConnector::READ_ONLY;
return $configuration;
......@@ -392,7 +392,7 @@ class AcquiaSearchConnector extends SolrConnectorPluginBase {
$this->connect();
$overridden = $this->solr->getEndpoint(self::ENDPOINT_KEY)->getOption('overridden_by_acquia_search');
if ($overridden === AcquiaSearchConnector::READ_ONLY) {
if ($overridden === SearchApiSolrAcquiaConnector::READ_ONLY) {
$message = 'The Search API Server serving this index is currently in read-only mode.';
\Drupal::logger('acquia_search')->error($message);
throw new \Exception($message);
......
......@@ -195,7 +195,7 @@ class PreferredSearchCore {
'sites_foldername' => $sites_foldername,
];
// The Acquia Search Solr module isn't configured properly.
// The Acquia Search module isn't configured properly.
if (!Storage::getIdentifier()) {
// Let other modules arbitrary alter the list possible cores.
\Drupal::moduleHandler()->alter('acquia_search_get_list_of_possible_cores', $possible_core_ids, $context);
......
......@@ -200,7 +200,7 @@ class RuntimeTest extends UnitTestCase {
$this->assertFalse(Runtime::isAcquiaServer($server->reveal()));
$server->getBackendConfig()->willReturn(['connector' => '1']);
$this->assertFalse(Runtime::isAcquiaServer($server->reveal()));
$server->getBackendConfig()->willReturn(['connector' => 'solr_acquia_search']);
$server->getBackendConfig()->willReturn(['connector' => 'solr_acquia_connector']);
$this->assertTrue(Runtime::isAcquiaServer($server->reveal()));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment