Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions .github/workflows/jump-start-config-sets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,39 @@ on:
- cron: '0 8 * * *' # run at 08:00 UTC

jobs:
test-grumphp:
runs-on: ubuntu-latest

env:
COMPOSER_MEMORY_LIMIT: -1

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, intl, gd, iconv, json, simplexml
ini-values: memory_limit=256M,post_max_size=256M
coverage: none

- name: Checkout search_api_solr
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Composer install
run: composer install

- name: Run GrumPHP
run: vendor/bin/grumphp run

generate-config-sets:
runs-on: ubuntu-latest

name: Generate Solr jump-start config-sets

needs: test-grumphp

env:
COMPOSER_MEMORY_LIMIT: -1
SEARCH_API_SOLR_JUMP_START_CONFIG_SET: 1
Expand Down Expand Up @@ -141,7 +169,7 @@ jobs:
name: jump-start-config-sets
path: search_api_solr/jump-start

run-tests:
test-phpunit:
runs-on: ubuntu-latest

needs: generate-config-sets
Expand Down Expand Up @@ -259,7 +287,7 @@ jobs:
vendor/bin/drush en search_api_spellcheck,search_api_autocomplete,facets,search_api_location --yes
vendor/bin/phpunit -v -c core --group search_api_solr --exclude-group not_drupal${{ matrix.drupal }},not_solr${{ matrix.solr }} modules/contrib/search_api_solr

run-legacy-tests:
test-phpunit-legacy:
runs-on: ubuntu-latest

needs: generate-config-sets
Expand Down Expand Up @@ -347,7 +375,7 @@ jobs:

name: Push updated Solr jump-start config-sets

needs: [run-tests, run-legacy-tests]
needs: [test-grumphp, test-phpunit, test-phpunit-legacy]

steps:
- name: Checkout search_api_solr
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ nbproject
composer.lock
InMemoriamOfPinkPony.rip
/tests/run_tests.sh
/grumphp.yml
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"drupal/geofield": "1.x-dev",
"drupal/search_api_autocomplete": "1.x-dev",
"drupal/search_api_location": "1.x-dev",
"drupal/search_api_spellcheck": "3.x-dev"
"drupal/search_api_spellcheck": "3.x-dev",
"drupal/coder": "^8.3",
"phpro/grumphp": "^1.3"
},
"conflict": {
"drupal/acquia_search_solr": "<1.0.0-beta8",
Expand All @@ -56,5 +58,11 @@
"drush.services.yml": "^9"
}
}
}
},
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
]
}
20 changes: 20 additions & 0 deletions grumphp.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
grumphp:
ascii:
failed: ~
succeeded: ~
fixer:
enabled: false

tasks:
phpcs:
standard:
- ./phpcs-ruleset.xml
triggered_by:
- php
- module
- inc
- theme
- install
ignore_patterns:
- vendor/
- node_modules/
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ function search_api_solr_defaults_requirements($phase) {
if (!isset($fields[$required_field])) {
$requirements['search_api_solr_defaults:' . $required_type_id . ':' . $required_field] = [
'severity' => REQUIREMENT_ERROR,
'description' => t('Field @field in content type @node_type not found. Solr Search Defaults module could not be installed', ['@node_type' => $required_type_id, '@field' => $required_field]),
'description' => t('Field @field in content type @node_type not found. Solr Search Defaults module could not be installed', [
'@node_type' => $required_type_id,
'@field' => $required_field,
]),
];
}
}
Expand All @@ -54,8 +57,8 @@ function search_api_solr_defaults_requirements($phase) {
/** @var \Drupal\Core\Entity\EntityTypeManager $entity_type_manager */
$entity_type_manager = \Drupal::service('entity_type.manager');
foreach ($entities_to_check as $entity_type => $entity_id) {
// Find out if the entity is already in place. If so, fail to install the
// module.
// Find out if the entity is already in place. If so, fail to install
// the module.
$entity_storage = $entity_type_manager->getStorage($entity_type);
$entity_storage->resetCache();
$entity = $entity_storage->load($entity_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\Tests\search_api_solr_defaults\Functional;

use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\search_api\Entity\Index;
use Drupal\search_api\Entity\Server;
use Drupal\search_api\IndexInterface;
Expand All @@ -17,6 +18,7 @@
class IntegrationTest extends BrowserTestBase {

use SolrCommitTrait;
use StringTranslationTrait;

/**
* The profile to install as a basis for testing.
Expand Down Expand Up @@ -182,7 +184,7 @@ public function testInstallAndDefaultSetupWorking() {
// because there was no content type "article".
$this->drupalGet('admin/modules');
$this->submitForm($edit_enable, 'Install');
$success_text = t('Content type @content_type not found. Solr Search Defaults module could not be installed.', ['@content_type' => 'article']);
$success_text = $this->t('Content type @content_type not found. Solr Search Defaults module could not be installed.', ['@content_type' => 'article']);
$this->assertSession()->pageTextContains($success_text);
}

Expand Down
7 changes: 6 additions & 1 deletion modules/search_api_solr_devel/search_api_solr_devel.module
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

/**
* @file
* Search API Solr Devel module.
*/

/**
* Implements hook_entity_type_alter().
*/
function search_api_solr_devel_entity_type_alter(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($entity_type->hasViewBuilderClass() && $entity_type->hasLinkTemplate('canonical')) {
$entity_type->setLinkTemplate('devel-solr', "/devel/$entity_type_id/{{$entity_type_id}}/solr");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class SearchApiSolrDevelCommands extends DrushCommands {
* The entity type manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* The module handler.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher
* The event dispatcher.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ public function entitySolr(RouteMatchInterface $route_match) {
if ($entity && $entity instanceof EntityInterface) {
foreach ($this->getBackends() as $backend_id) {
/** @var \Drupal\search_api\ServerInterface[] $servers */
$servers = $this->storage->loadByProperties(['backend' => $backend_id, 'status' => TRUE]);
$servers = $this->storage->loadByProperties([
'backend' => $backend_id,
'status' => TRUE,
]);
foreach ($servers as $server) {
/** @var \Drupal\search_api\ServerInterface $server */
/** @var \Drupal\search_api_solr\SolrBackendInterface $backend */
Expand All @@ -173,7 +176,7 @@ public function entitySolr(RouteMatchInterface $route_match) {
$items = [];
$base_summary_row = $this->getBaseRow($server, $index, $datasource_id, $entity, $langcode, $item_id);

// @TODO: Run a timer on this process and report it?
// @todo Run a timer on this process and report it?
$items[$item_id] = $this->fieldsHelper->createItemFromObject($index, $entity->getTranslation($langcode)->getTypedData(), $item_id);
// Alter and preprocess the items to indexed.
$index->alterIndexedItems($items);
Expand Down Expand Up @@ -216,7 +219,7 @@ public function entitySolr(RouteMatchInterface $route_match) {
$query->setQuery('id:"' . $fields['id'] . '"');
$query->setFields('*');
try {
// @TODO: Run a timer on this process and report it?
// @todo Run a timer on this process and report it?
$results = $solr->execute($query, $backend->getCollectionEndpoint($index));
$num_found = $results->getNumFound();
$summary_row['solr_exists'] = $this->t('yes');
Expand Down
21 changes: 11 additions & 10 deletions modules/search_api_solr_devel/src/Logging/SolariumRequestLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

use Drupal\Component\Utility\Timer;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Component\Serialization\Json;
use Drupal\devel\DevelDumperManagerInterface;
use Drupal\search_api\LoggerTrait;
use Drupal\search_api_solr\Utility\Utility;
use Solarium\Core\Client\Adapter\AdapterHelper;
use Solarium\Core\Event\Events;
use Solarium\QueryType\Select\Query\Query;
Expand Down Expand Up @@ -59,7 +57,7 @@ public function postCreateQuery($event) {
/** @var \Solarium\Core\Event\PostCreateQuery $event */
$query = $event->getQuery();
if ($query instanceof Query) {
/** @var $query */
/** @var \Solarium\QueryType\Select\Query\Query $query */
$query->getDebug();
$query->addParam('echoParams', 'all')
->setOmitHeader(FALSE);
Expand All @@ -69,11 +67,11 @@ public function postCreateQuery($event) {
/**
* Show debug message and a data object dump.
*
* @param $counter int
* @param int $counter
* The current Solr query counter.
* @param $data mixed
* @param mixed $data
* Data to dump.
* @param $message string
* @param string $message
* Message to show.
*/
public function showMessage($counter, $data, $message) {
Expand All @@ -84,7 +82,7 @@ public function showMessage($counter, $data, $message) {
/**
* Start timer for a query.
*
* @param $counter int
* @param int $counter
* The current Solr query counter.
*/
public function timerStart($counter) {
Expand All @@ -94,8 +92,9 @@ public function timerStart($counter) {
/**
* Returns timer for a query.
*
* @param $counter int
* @param int $counter
* The current Solr query counter.
*
* @return array
* The timer array.
*/
Expand All @@ -106,9 +105,10 @@ public function timerStop($counter) {
/**
* Determine which Solr requests should be ignored.
*
* @param $handler string
* @param string $handler
* The Solr handler. Examples: "admin/ping", "select", etc.
* @return boolean
*
* @return bool
* TRUE when we should skip debugging this query.
*/
public function shouldIgnore($handler) {
Expand Down Expand Up @@ -183,4 +183,5 @@ public function postExecuteRequest($event) {
// Log raw data to file (using NULL plugin)
$this->develDumperManager->debug($debug, 'Search API Solr Debug: Response', 'default');
}

}
5 changes: 5 additions & 0 deletions modules/search_api_solr_legacy/search_api_solr_legacy.install
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php

/**
* @file
* Install, update and uninstall functions for Search API Solr Legacy.
*/

/**
* Install new field types for legacy Solr versions.
*/
Expand Down
5 changes: 3 additions & 2 deletions modules/search_api_solr_legacy/search_api_solr_legacy.module
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

/**
* @file
* Search API Solr Legacy module.
*/

use Drupal\Core\Form\FormStateInterface;

/**
* Implements hook_form_FORM_alter.
* Implements hook_form_FORM_ID_alter() for search_api_server_form.
*/
function search_api_solr_legacy_form_search_api_server_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// We need to restrict by form ID here because this function is also called
Expand All @@ -28,7 +29,7 @@ function search_api_solr_legacy_form_search_api_server_form_alter(&$form, FormSt
}

/**
*
* Implements hook_search_api_solr_configset_template_mapping_alter().
*/
function search_api_solr_legacy_search_api_solr_configset_template_mapping_alter(&$solr_configset_template_mapping) {
$template_path = drupal_get_path('module', 'search_api_solr_legacy') . '/solr-conf-templates/';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@ public static function adjustBackendConfig($config_name) {
$search_api_index_storage = \Drupal::entityTypeManager()->getStorage('search_api_index');
$search_api_index_storage->resetCache();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ protected function adjustBackendConfig() {
public function testViewsAdmin() {
$this->markTestSkipped('This test fails on Solr 3.6. It requires some more debugging.');
}

}
21 changes: 16 additions & 5 deletions modules/search_api_solr_legacy/tests/src/Kernel/SolrLegacyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testConfigGeneration(array $files) {
}
}

$config_name = 'name="drupal-' . SolrBackendInterface::SEARCH_API_SOLR_MIN_SCHEMA_VERSION . '-solr-' . $solr_major_version . '.x-'. SEARCH_API_SOLR_JUMP_START_CONFIG_SET .'"';
$config_name = 'name="drupal-' . SolrBackendInterface::SEARCH_API_SOLR_MIN_SCHEMA_VERSION . '-solr-' . $solr_major_version . '.x-' . SEARCH_API_SOLR_JUMP_START_CONFIG_SET . '"';
$this->assertStringContainsString($config_name, $config_files['solrconfig.xml']);
$this->assertStringContainsString($config_name, $config_files['schema.xml']);
$this->assertStringContainsString($server->id(), $config_files['test.txt']);
Expand All @@ -77,8 +77,19 @@ public function testConfigGeneration(array $files) {
$this->assertStringNotContainsString('<statsCache', $config_files['solrconfig.xml']);

$backend_config['connector_config']['jmx'] = TRUE;
$backend_config['disabled_field_types'] = ['text_foo_en_3_6_0', 'text_foo_en_4_5_0', 'text_foo_en_6_0_0', 'text_de_3_6_0', 'text_de_4_5_0', 'text_de_6_0_0', 'text_de_7_0_0'];
$backend_config['disabled_caches'] = ['cache_document_default_7_0_0', 'cache_filter_default_7_0_0'];
$backend_config['disabled_field_types'] = [
'text_foo_en_3_6_0',
'text_foo_en_4_5_0',
'text_foo_en_6_0_0',
'text_de_3_6_0',
'text_de_4_5_0',
'text_de_6_0_0',
'text_de_7_0_0',
];
$backend_config['disabled_caches'] = [
'cache_document_default_7_0_0',
'cache_filter_default_7_0_0',
];
$server->setBackendConfig($backend_config);
$server->save();
// Reset static caches.
Expand All @@ -105,7 +116,7 @@ public function testConfigGeneration(array $files) {
* Data provider for testConfigGeneration method.
*/
public function configGenerationDataProvider() {
// @codingStandardsIgnoreStart
// phpcs:disable
return [[[
'schema.xml' => [
# phonetic is currently not available for Solr <= 7.x.
Expand Down Expand Up @@ -173,7 +184,7 @@ public function configGenerationDataProvider() {
'hook_search_api_solr_config_files_alter() works'
],
]]];
// @codingStandardsIgnoreEnd
// phpcs:enable
}

}
Loading