From c5baab3a3da4f3ad5fdb849964952b6f24156736 Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Wed, 15 Jan 2025 11:54:14 -0800 Subject: [PATCH 01/17] update basic module stuff for 11 --- composer.json | 10 +++++----- .../search_api_pantheon_admin.info.yml | 2 +- .../search_api_pantheon_examples.info.yml | 2 +- search_api_pantheon.info.yml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 58039df4..e6b32dfb 100644 --- a/composer.json +++ b/composer.json @@ -43,14 +43,14 @@ "ext-zip": "*", "drupal/search_api_solr": "^4.3", "guzzlehttp/guzzle": "^6.5.7|^7.5", - "http-interop/http-factory-guzzle": "^1.0", - "kint-php/kint": "^4.1|^5", + "guzzlehttp/psr7": "^2.7", + "kint-php/kint": "^5|^6", "psr/event-dispatcher": "^1.0", - "symfony/finder": "^4.4|^5|^6", - "symfony/yaml": "^4.4|^5|^6" + "symfony/finder": "^6|^7", + "symfony/yaml": "^6|^7" }, "require-dev": { - "consolidation/robo": "^3.0", + "consolidation/robo": "^4", "czproject/git-php": "^4.0", "drupal/coder": "@stable", "phpunit/phpunit": "@stable", diff --git a/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml b/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml index 55910169..caeff4b1 100644 --- a/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml +++ b/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon Admin type: module description: Administer a Pantheon Search server -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^9.4 || ^10 || ^11 package: Search dependencies: - search_api_solr:search_api_solr diff --git a/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml b/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml index dbf6b77e..62efa38a 100644 --- a/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml +++ b/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon Examples type: module description: Contains some examples of things you could do with Search API Pantheon module. This module should not be enabled in prod. -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^9.4 || ^10 || ^11 package: Search dependencies: - search_api_pantheon:search_api_pantheon diff --git a/search_api_pantheon.info.yml b/search_api_pantheon.info.yml index 46e2f95a..f0bb27b8 100644 --- a/search_api_pantheon.info.yml +++ b/search_api_pantheon.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon type: module description: Search API + Solr + Pantheon integration -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^9.4 || ^10 || ^11 package: Search dependencies: - search_api_solr:search_api_solr From 9e500981cf4e3fc01fd74ed096909d151e39f230 Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Wed, 15 Jan 2025 11:57:49 -0800 Subject: [PATCH 02/17] small update --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e6b32dfb..503e9292 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ } }, "require": { - "php": ">=7.4", + "php": ">=8.3", "ext-curl": "*", "ext-json": "*", "ext-zip": "*", From 4209693754d786078d4aa769371f5c2c82668a01 Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Wed, 15 Jan 2025 12:01:01 -0800 Subject: [PATCH 03/17] test on newer php --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dfe4a723..7cc899d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: linting: runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.1 + image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 options: --user root name: Code linting env: @@ -45,15 +45,15 @@ jobs: - name: PHPCompatibility uses: pantheon-systems/phpcompatibility-action@v1 with: - test-versions: 7.4- + test-versions: 8.2 build_test: strategy: matrix: - drupal-version: [ 10 ] + drupal-version: [ 10, 11 ] fail-fast: false runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.1 + image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 options: --user root name: Build and test (Drupal ${{ matrix.drupal-version }}) env: From 53f33be8bb80c01b551d473c7de84e6602a7080e Mon Sep 17 00:00:00 2001 From: CI Bot Date: Thu, 16 Jan 2025 10:00:15 -0500 Subject: [PATCH 04/17] update dependencies and solarium client --- composer.json | 4 ++-- search_api_pantheon.info.yml | 2 +- src/Services/SolariumClient.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 58039df4..e3c69c68 100644 --- a/composer.json +++ b/composer.json @@ -46,8 +46,8 @@ "http-interop/http-factory-guzzle": "^1.0", "kint-php/kint": "^4.1|^5", "psr/event-dispatcher": "^1.0", - "symfony/finder": "^4.4|^5|^6", - "symfony/yaml": "^4.4|^5|^6" + "symfony/finder": "^4.4|^5|^6|^7", + "symfony/yaml": "^4.4|^5|^6|^7" }, "require-dev": { "consolidation/robo": "^3.0", diff --git a/search_api_pantheon.info.yml b/search_api_pantheon.info.yml index 46e2f95a..f0bb27b8 100644 --- a/search_api_pantheon.info.yml +++ b/search_api_pantheon.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon type: module description: Search API + Solr + Pantheon integration -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^9.4 || ^10 || ^11 package: Search dependencies: - search_api_solr:search_api_solr diff --git a/src/Services/SolariumClient.php b/src/Services/SolariumClient.php index 3afd20d2..89dd610d 100644 --- a/src/Services/SolariumClient.php +++ b/src/Services/SolariumClient.php @@ -10,7 +10,7 @@ use Solarium\Core\Query\Result\ResultInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\search_api_pantheon\Solarium\EventDispatcher\Psr14Bridge; -use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcher; /** * Customized Solrium Client to send Guzzle debugging to log entries. @@ -21,7 +21,7 @@ class SolariumClient extends Client { /** * Class constructor. */ - public function __construct(PantheonGuzzle $guzzle, Endpoint $endpoint, LoggerChannelFactoryInterface $logger_factory, ContainerAwareEventDispatcher $event_dispatcher) { + public function __construct(PantheonGuzzle $guzzle, Endpoint $endpoint, LoggerChannelFactoryInterface $logger_factory, EventDispatcher $event_dispatcher) { $drupal_major_parts = explode('.', \Drupal::VERSION); $drupal_major = reset($drupal_major_parts); if ($drupal_major < 9) { From c0a306ea9d3bdf338ba28821510304b630d12636 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Thu, 16 Jan 2025 10:11:03 -0500 Subject: [PATCH 05/17] remove overrides of drush logger to prevent errors --- drush.services.yml | 10 +++++----- src/Commands/Diagnose.php | 5 ----- src/Commands/Query.php | 5 ----- src/Commands/Reload.php | 6 ------ src/Commands/Schema.php | 6 ------ src/Commands/TestIndexAndQuery.php | 5 ----- 6 files changed, 5 insertions(+), 32 deletions(-) diff --git a/drush.services.yml b/drush.services.yml index 2be3d265..eccdd7be 100644 --- a/drush.services.yml +++ b/drush.services.yml @@ -1,26 +1,26 @@ services: search_api_pantheon.drush_diagnose: class: \Drupal\search_api_pantheon\Commands\Diagnose - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] tags: - { name: drush.command } search_api_pantheon.drush_test_index_and_query: class: \Drupal\search_api_pantheon\Commands\TestIndexAndQuery - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] tags: - { name: drush.command } search_api_pantheon.drush_schema: class: \Drupal\search_api_pantheon\Commands\Schema - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.schema_poster" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.schema_poster" ] tags: - { name: drush.command } search_api_pantheon.drush_query: class: \Drupal\search_api_pantheon\Commands\Query - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] tags: - { name: drush.command } search_api_pantheon.drush_reload: class: \Drupal\search_api_pantheon\Commands\Reload - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.schema_poster" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.schema_poster" ] tags: - { name: drush.command } diff --git a/src/Commands/Diagnose.php b/src/Commands/Diagnose.php index 1ec37214..37424a46 100644 --- a/src/Commands/Diagnose.php +++ b/src/Commands/Diagnose.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\search_api_pantheon\Services\Endpoint; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SolariumClient; @@ -31,8 +30,6 @@ class Diagnose extends DrushCommands { /** * Class Constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\Endpoint $endpoint @@ -41,12 +38,10 @@ class Diagnose extends DrushCommands { * Injected by container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, Endpoint $endpoint, SolariumClient $solariumClient ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->endpoint = $endpoint; $this->solr = $solariumClient; diff --git a/src/Commands/Query.php b/src/Commands/Query.php index f246c8f0..2ca97677 100644 --- a/src/Commands/Query.php +++ b/src/Commands/Query.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\search_api_pantheon\Services\Endpoint; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SolariumClient; @@ -30,8 +29,6 @@ class Query extends DrushCommands { /** * Class Constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\Endpoint $endpoint @@ -40,12 +37,10 @@ class Query extends DrushCommands { * Injected by container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, Endpoint $endpoint, SolariumClient $solariumClient ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->endpoint = $endpoint; $this->solr = $solariumClient; diff --git a/src/Commands/Reload.php b/src/Commands/Reload.php index 9b42b482..52fad527 100644 --- a/src/Commands/Reload.php +++ b/src/Commands/Reload.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Logger\LoggerChannelTrait; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SchemaPoster; @@ -12,7 +11,6 @@ * Drush Search Api Pantheon Schema Commands. */ class Reload extends DrushCommands { - use LoggerChannelTrait; /** * Configured pantheon-solr-specific guzzle client. @@ -31,19 +29,15 @@ class Reload extends DrushCommands { /** * Class constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\SchemaPoster $schemaPoster * Injected by Container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, SchemaPoster $schemaPoster ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->schemaPoster = $schemaPoster; } diff --git a/src/Commands/Schema.php b/src/Commands/Schema.php index c43b37dc..e9e605e1 100644 --- a/src/Commands/Schema.php +++ b/src/Commands/Schema.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Logger\LoggerChannelTrait; use Drupal\search_api_pantheon\Plugin\SolrConnector\PantheonSolrConnector; use Drupal\search_api_pantheon\Services\PantheonGuzzle; @@ -14,7 +13,6 @@ * Drush Search Api Pantheon Schema Commands. */ class Schema extends DrushCommands { - use LoggerChannelTrait; /** * Configured pantheon-solr-specific guzzle client. @@ -33,19 +31,15 @@ class Schema extends DrushCommands { /** * Class constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\SchemaPoster $schemaPoster * Injected by Container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, SchemaPoster $schemaPoster ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->schemaPoster = $schemaPoster; } diff --git a/src/Commands/TestIndexAndQuery.php b/src/Commands/TestIndexAndQuery.php index e0c23140..99b38a29 100644 --- a/src/Commands/TestIndexAndQuery.php +++ b/src/Commands/TestIndexAndQuery.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\search_api_pantheon\Services\Endpoint; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SolariumClient; @@ -35,8 +34,6 @@ class TestIndexAndQuery extends DrushCommands { /** * Class Constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\Endpoint $endpoint @@ -45,12 +42,10 @@ class TestIndexAndQuery extends DrushCommands { * Injected by container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, Endpoint $endpoint, SolariumClient $solariumClient ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->endpoint = $endpoint; $this->solr = $solariumClient; From 218720c36b7a81ccea4ca1bac6618c5f0ff2df77 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Thu, 16 Jan 2025 10:26:22 -0500 Subject: [PATCH 06/17] make submodules d11 compatible --- .../search_api_pantheon_admin.info.yml | 2 +- .../search_api_pantheon_examples.info.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml b/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml index 55910169..caeff4b1 100644 --- a/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml +++ b/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon Admin type: module description: Administer a Pantheon Search server -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^9.4 || ^10 || ^11 package: Search dependencies: - search_api_solr:search_api_solr diff --git a/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml b/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml index dbf6b77e..62efa38a 100644 --- a/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml +++ b/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon Examples type: module description: Contains some examples of things you could do with Search API Pantheon module. This module should not be enabled in prod. -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^9.4 || ^10 || ^11 package: Search dependencies: - search_api_pantheon:search_api_pantheon From 7f0e0d39cb2b30e41b4b0e7c0389ce1e5e20e508 Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Thu, 16 Jan 2025 09:58:41 -0800 Subject: [PATCH 07/17] removing configs for possible D11 install --- composer.json | 4 +- .../search_api.server.pantheon_solr8.yml | 50 ------------ .../search_api_index.content_index.yml | 76 ------------------- ...api_pantheon.connector.pantheon.schema.yml | 3 - 4 files changed, 2 insertions(+), 131 deletions(-) delete mode 100644 config/install/search_api.server.pantheon_solr8.yml delete mode 100644 config/optional/search_api_index.content_index.yml delete mode 100644 config/schema/search_api_pantheon.connector.pantheon.schema.yml diff --git a/composer.json b/composer.json index 503e9292..4f9605a4 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "preferred-install": "dist", "sort-packages": true, "platform": { - "php": "8.0" + "php": "8.2" }, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true @@ -37,7 +37,7 @@ } }, "require": { - "php": ">=8.3", + "php": ">=8.2", "ext-curl": "*", "ext-json": "*", "ext-zip": "*", diff --git a/config/install/search_api.server.pantheon_solr8.yml b/config/install/search_api.server.pantheon_solr8.yml deleted file mode 100644 index dac34341..00000000 --- a/config/install/search_api.server.pantheon_solr8.yml +++ /dev/null @@ -1,50 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - search_api_solr.solr_request_handler.request_handler_autocomplete_default_7_0_0 - - search_api_solr.solr_request_handler.request_handler_elevate_default_7_0_0 - - search_api_solr.solr_request_handler.request_handler_extract_default_7_0_0 - - search_api_solr.solr_request_handler.request_handler_mlt_default_7_0_0 - - search_api_solr.solr_request_handler.request_handler_select_default_7_0_0 - - search_api_solr.solr_request_handler.request_handler_spell_default_7_0_0 - - search_api_solr.solr_request_handler.request_handler_suggest_default_7_0_0 - - search_api_solr.solr_request_handler.request_handler_tvrh_default_7_0_0 - module: - - search_api_pantheon - - search_api_solr -id: pantheon_solr8 -name: 'Pantheon Search' -description: '' -backend: search_api_solr -backend_config: - connector: pantheon - connector_config: - timeout: 5 - index_timeout: 5 - optimize_timeout: 10 - finalize_timeout: 30 - skip_schema_check: true - solr_version: '8' - http_method: AUTO - commit_within: 1000 - jmx: false - jts: false - solr_install_dir: '' - disabled_field_types: { } - disabled_caches: { } - disabled_request_handlers: - - request_handler_replicationslave_default_7_0_0 - - request_handler_replicationmaster_default_7_0_0 - disabled_request_dispatchers: - - request_dispatcher_httpcachingnever_default_7_0_0 - rows: 10 - index_single_documents_fallback_count: 10 - retrieve_data: false - highlight_data: false - fallback_multiple: false - server_prefix: '' - domain: generic - environment: default - optimize: false - site_hash: false diff --git a/config/optional/search_api_index.content_index.yml b/config/optional/search_api_index.content_index.yml deleted file mode 100644 index 95e331f7..00000000 --- a/config/optional/search_api_index.content_index.yml +++ /dev/null @@ -1,76 +0,0 @@ -langcode: en -status: true -dependencies: - module: - - search_api_solr - - search_api - - node - config: - - search_api.server.pantheon_solr8 -third_party_settings: - search_api_solr: - finalize: false - commit_before_finalize: false - commit_after_finalize: false - multilingual: - limit_to_content_language: false - include_language_independent: true - highlighter: - maxAnalyzedChars: 51200 - fragmenter: gap - regex: - slop: 0.5 - pattern: blank - maxAnalyzedChars: 10000 - usePhraseHighlighter: true - highlightMultiTerm: true - preserveMulti: false - highlight: - mergeContiguous: false - requireFieldMatch: false - snippets: 3 - fragsize: 0 - mlt: - mintf: 1 - mindf: 1 - maxdf: 0 - maxdfpct: 0 - minwl: 0 - maxwl: 0 - maxqt: 100 - maxntp: 2000 - boost: false - interestingTerms: none - term_modifiers: - slop: 3 - fuzzy: 1 - advanced: - index_prefix: '' - collection: '' - timezone: '' -id: content_index -name: 'Basic Content Index' -description: 'An example index to get started with Solr 8 searching.' -read_only: false -field_settings: { } -datasource_settings: - 'entity:node': - bundles: - default: true - selected: { } - languages: - default: true - selected: { } -processor_settings: - add_url: { } - aggregated_field: { } - language_with_fallback: { } - rendered_item: { } - solr_date_range: { } -tracker_settings: - default: - indexing_order: fifo -options: - index_directly: true - cron_limit: 50 -server: pantheon_solr8 diff --git a/config/schema/search_api_pantheon.connector.pantheon.schema.yml b/config/schema/search_api_pantheon.connector.pantheon.schema.yml deleted file mode 100644 index 122d171f..00000000 --- a/config/schema/search_api_pantheon.connector.pantheon.schema.yml +++ /dev/null @@ -1,3 +0,0 @@ -plugin.plugin_configuration.search_api_solr_connector.pantheon: - type: plugin.plugin_configuration.search_api_solr_connector.standard - label: 'Search API Solr Pantheon connector settings' From e81620cdbc594299fc8d26c7fbada4ff2227a9d2 Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Tue, 21 Jan 2025 14:55:07 -0800 Subject: [PATCH 08/17] event dispatcher interface --- src/Services/SolariumClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Services/SolariumClient.php b/src/Services/SolariumClient.php index 3afd20d2..48be55d9 100644 --- a/src/Services/SolariumClient.php +++ b/src/Services/SolariumClient.php @@ -10,7 +10,7 @@ use Solarium\Core\Query\Result\ResultInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\search_api_pantheon\Solarium\EventDispatcher\Psr14Bridge; -use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Customized Solrium Client to send Guzzle debugging to log entries. @@ -21,7 +21,7 @@ class SolariumClient extends Client { /** * Class constructor. */ - public function __construct(PantheonGuzzle $guzzle, Endpoint $endpoint, LoggerChannelFactoryInterface $logger_factory, ContainerAwareEventDispatcher $event_dispatcher) { + public function __construct(PantheonGuzzle $guzzle, Endpoint $endpoint, LoggerChannelFactoryInterface $logger_factory, EventDispatcherInterface $event_dispatcher) { $drupal_major_parts = explode('.', \Drupal::VERSION); $drupal_major = reset($drupal_major_parts); if ($drupal_major < 9) { From ddf91147bc08852e29ba065e95d2adbd621838b7 Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Tue, 21 Jan 2025 15:28:55 -0800 Subject: [PATCH 09/17] psr18adapter --- composer.json | 2 +- src/Services/PantheonGuzzle.php | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 4f9605a4..bc0a5cb2 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "ext-json": "*", "ext-zip": "*", "drupal/search_api_solr": "^4.3", - "guzzlehttp/guzzle": "^6.5.7|^7.5", + "guzzlehttp/guzzle": "^7.5", "guzzlehttp/psr7": "^2.7", "kint-php/kint": "^5|^6", "psr/event-dispatcher": "^1.0", diff --git a/src/Services/PantheonGuzzle.php b/src/Services/PantheonGuzzle.php index 55e9b256..a56d0975 100644 --- a/src/Services/PantheonGuzzle.php +++ b/src/Services/PantheonGuzzle.php @@ -26,7 +26,8 @@ */ class PantheonGuzzle extends Client implements ClientInterface, - LoggerAwareInterface { + LoggerAwareInterface, + Psr18Adapter { use LoggerAwareTrait; use EndpointAwareTrait; @@ -142,11 +143,7 @@ public function getQueryResult( * The interface in question. */ public function getPsr18Adapter(): AdapterInterface { - return new Psr18Adapter( - $this, - new RequestFactory(), - new StreamFactory() - ); + return $this; } /** From ed297a3bd5d1e6bff986b858adeeda760780a44f Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Tue, 21 Jan 2025 15:32:30 -0800 Subject: [PATCH 10/17] guzzle 7 is psr18 compatible --- src/Services/PantheonGuzzle.php | 16 +--------------- src/Services/SolariumClient.php | 2 +- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/Services/PantheonGuzzle.php b/src/Services/PantheonGuzzle.php index a56d0975..cb53328b 100644 --- a/src/Services/PantheonGuzzle.php +++ b/src/Services/PantheonGuzzle.php @@ -7,15 +7,12 @@ use GuzzleHttp\Handler\CurlHandler; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; -use Http\Factory\Guzzle\RequestFactory; -use Http\Factory\Guzzle\StreamFactory; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Solarium\Core\Client\Adapter\AdapterInterface; -use Solarium\Core\Client\Adapter\Psr18Adapter; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Session\AccountProxyInterface; @@ -26,8 +23,7 @@ */ class PantheonGuzzle extends Client implements ClientInterface, - LoggerAwareInterface, - Psr18Adapter { + LoggerAwareInterface { use LoggerAwareTrait; use EndpointAwareTrait; @@ -136,16 +132,6 @@ public function getQueryResult( return (string) $response->getBody(); } - /** - * Get a PSR adapter interface based on this class. - * - * @return \Solarium\Core\Client\Adapter\AdapterInterface - * The interface in question. - */ - public function getPsr18Adapter(): AdapterInterface { - return $this; - } - /** * Request Middleware Callback. * diff --git a/src/Services/SolariumClient.php b/src/Services/SolariumClient.php index 48be55d9..595c221a 100644 --- a/src/Services/SolariumClient.php +++ b/src/Services/SolariumClient.php @@ -29,7 +29,7 @@ public function __construct(PantheonGuzzle $guzzle, Endpoint $endpoint, LoggerCh $event_dispatcher = new Psr14Bridge($event_dispatcher); } parent::__construct( - $guzzle->getPsr18Adapter(), + $guzzle, $event_dispatcher, ['endpoint' => [$endpoint]] ); From 703450192afcf97a742d819a612b8df4f1c877b8 Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Tue, 21 Jan 2025 15:44:23 -0800 Subject: [PATCH 11/17] Adapter Interface --- src/Services/PantheonGuzzle.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Services/PantheonGuzzle.php b/src/Services/PantheonGuzzle.php index cb53328b..3e4f4786 100644 --- a/src/Services/PantheonGuzzle.php +++ b/src/Services/PantheonGuzzle.php @@ -23,7 +23,8 @@ */ class PantheonGuzzle extends Client implements ClientInterface, - LoggerAwareInterface { + LoggerAwareInterface, + AdapterInterface { use LoggerAwareTrait; use EndpointAwareTrait; From c4afc5cf10ddf47ddc040afeaedca30b7ca8e28a Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Tue, 21 Jan 2025 15:56:42 -0800 Subject: [PATCH 12/17] renaming because codacy blows --- .phpcs.xml => phpcs.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .phpcs.xml => phpcs.xml (100%) diff --git a/.phpcs.xml b/phpcs.xml similarity index 100% rename from .phpcs.xml rename to phpcs.xml From 3337e46743c543ea2359c06ed7ca5f61e84c97ca Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Wed, 22 Jan 2025 08:40:10 -0800 Subject: [PATCH 13/17] Squashed commit of the following: commit 218720c36b7a81ccea4ca1bac6618c5f0ff2df77 Author: CI Bot Date: Thu Jan 16 10:26:22 2025 -0500 make submodules d11 compatible commit c0a306ea9d3bdf338ba28821510304b630d12636 Author: CI Bot Date: Thu Jan 16 10:11:03 2025 -0500 remove overrides of drush logger to prevent errors commit 53f33be8bb80c01b551d473c7de84e6602a7080e Author: CI Bot Date: Thu Jan 16 10:00:15 2025 -0500 update dependencies and solarium client --- composer.json | 4 ++-- drush.services.yml | 10 +++++----- src/Commands/Diagnose.php | 5 ----- src/Commands/Query.php | 5 ----- src/Commands/Reload.php | 6 ------ src/Commands/Schema.php | 6 ------ src/Commands/TestIndexAndQuery.php | 5 ----- src/Services/SolariumClient.php | 4 ++-- 8 files changed, 9 insertions(+), 36 deletions(-) diff --git a/composer.json b/composer.json index bc0a5cb2..ced543bd 100644 --- a/composer.json +++ b/composer.json @@ -46,8 +46,8 @@ "guzzlehttp/psr7": "^2.7", "kint-php/kint": "^5|^6", "psr/event-dispatcher": "^1.0", - "symfony/finder": "^6|^7", - "symfony/yaml": "^6|^7" + "symfony/finder": "^4.4|^5|^6|^7", + "symfony/yaml": "^4.4|^5|^6|^7" }, "require-dev": { "consolidation/robo": "^4", diff --git a/drush.services.yml b/drush.services.yml index 2be3d265..eccdd7be 100644 --- a/drush.services.yml +++ b/drush.services.yml @@ -1,26 +1,26 @@ services: search_api_pantheon.drush_diagnose: class: \Drupal\search_api_pantheon\Commands\Diagnose - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] tags: - { name: drush.command } search_api_pantheon.drush_test_index_and_query: class: \Drupal\search_api_pantheon\Commands\TestIndexAndQuery - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] tags: - { name: drush.command } search_api_pantheon.drush_schema: class: \Drupal\search_api_pantheon\Commands\Schema - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.schema_poster" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.schema_poster" ] tags: - { name: drush.command } search_api_pantheon.drush_query: class: \Drupal\search_api_pantheon\Commands\Query - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.endpoint", "@search_api_pantheon.solarium_client" ] tags: - { name: drush.command } search_api_pantheon.drush_reload: class: \Drupal\search_api_pantheon\Commands\Reload - arguments: [ "@logger.factory", "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.schema_poster" ] + arguments: [ "@search_api_pantheon.pantheon_guzzle", "@search_api_pantheon.schema_poster" ] tags: - { name: drush.command } diff --git a/src/Commands/Diagnose.php b/src/Commands/Diagnose.php index 1ec37214..37424a46 100644 --- a/src/Commands/Diagnose.php +++ b/src/Commands/Diagnose.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\search_api_pantheon\Services\Endpoint; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SolariumClient; @@ -31,8 +30,6 @@ class Diagnose extends DrushCommands { /** * Class Constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\Endpoint $endpoint @@ -41,12 +38,10 @@ class Diagnose extends DrushCommands { * Injected by container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, Endpoint $endpoint, SolariumClient $solariumClient ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->endpoint = $endpoint; $this->solr = $solariumClient; diff --git a/src/Commands/Query.php b/src/Commands/Query.php index f246c8f0..2ca97677 100644 --- a/src/Commands/Query.php +++ b/src/Commands/Query.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\search_api_pantheon\Services\Endpoint; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SolariumClient; @@ -30,8 +29,6 @@ class Query extends DrushCommands { /** * Class Constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\Endpoint $endpoint @@ -40,12 +37,10 @@ class Query extends DrushCommands { * Injected by container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, Endpoint $endpoint, SolariumClient $solariumClient ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->endpoint = $endpoint; $this->solr = $solariumClient; diff --git a/src/Commands/Reload.php b/src/Commands/Reload.php index 9b42b482..52fad527 100644 --- a/src/Commands/Reload.php +++ b/src/Commands/Reload.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Logger\LoggerChannelTrait; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SchemaPoster; @@ -12,7 +11,6 @@ * Drush Search Api Pantheon Schema Commands. */ class Reload extends DrushCommands { - use LoggerChannelTrait; /** * Configured pantheon-solr-specific guzzle client. @@ -31,19 +29,15 @@ class Reload extends DrushCommands { /** * Class constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\SchemaPoster $schemaPoster * Injected by Container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, SchemaPoster $schemaPoster ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->schemaPoster = $schemaPoster; } diff --git a/src/Commands/Schema.php b/src/Commands/Schema.php index c43b37dc..e9e605e1 100644 --- a/src/Commands/Schema.php +++ b/src/Commands/Schema.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Logger\LoggerChannelTrait; use Drupal\search_api_pantheon\Plugin\SolrConnector\PantheonSolrConnector; use Drupal\search_api_pantheon\Services\PantheonGuzzle; @@ -14,7 +13,6 @@ * Drush Search Api Pantheon Schema Commands. */ class Schema extends DrushCommands { - use LoggerChannelTrait; /** * Configured pantheon-solr-specific guzzle client. @@ -33,19 +31,15 @@ class Schema extends DrushCommands { /** * Class constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\SchemaPoster $schemaPoster * Injected by Container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, SchemaPoster $schemaPoster ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->schemaPoster = $schemaPoster; } diff --git a/src/Commands/TestIndexAndQuery.php b/src/Commands/TestIndexAndQuery.php index e0c23140..99b38a29 100644 --- a/src/Commands/TestIndexAndQuery.php +++ b/src/Commands/TestIndexAndQuery.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\search_api_pantheon\Services\Endpoint; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SolariumClient; @@ -35,8 +34,6 @@ class TestIndexAndQuery extends DrushCommands { /** * Class Constructor. * - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory - * Injected by container. * @param \Drupal\search_api_pantheon\Services\PantheonGuzzle $pantheonGuzzle * Injected by container. * @param \Drupal\search_api_pantheon\Services\Endpoint $endpoint @@ -45,12 +42,10 @@ class TestIndexAndQuery extends DrushCommands { * Injected by container. */ public function __construct( - LoggerChannelFactoryInterface $loggerChannelFactory, PantheonGuzzle $pantheonGuzzle, Endpoint $endpoint, SolariumClient $solariumClient ) { - $this->logger = $loggerChannelFactory->get('SearchAPIPantheon Drush'); $this->pantheonGuzzle = $pantheonGuzzle; $this->endpoint = $endpoint; $this->solr = $solariumClient; diff --git a/src/Services/SolariumClient.php b/src/Services/SolariumClient.php index 595c221a..b0bfc3f6 100644 --- a/src/Services/SolariumClient.php +++ b/src/Services/SolariumClient.php @@ -10,7 +10,7 @@ use Solarium\Core\Query\Result\ResultInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\search_api_pantheon\Solarium\EventDispatcher\Psr14Bridge; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; /** * Customized Solrium Client to send Guzzle debugging to log entries. @@ -21,7 +21,7 @@ class SolariumClient extends Client { /** * Class constructor. */ - public function __construct(PantheonGuzzle $guzzle, Endpoint $endpoint, LoggerChannelFactoryInterface $logger_factory, EventDispatcherInterface $event_dispatcher) { + public function __construct(PantheonGuzzle $guzzle, Endpoint $endpoint, LoggerChannelFactoryInterface $logger_factory, EventDispatcher $event_dispatcher) { $drupal_major_parts = explode('.', \Drupal::VERSION); $drupal_major = reset($drupal_major_parts); if ($drupal_major < 9) { From 8ddc50c31688bde2644249757a6053bb4a1d0463 Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Wed, 22 Jan 2025 11:13:38 -0800 Subject: [PATCH 14/17] Fixing issues with Event Dispatcher restoring psr 18 code d9 is EOL restoring get Adapter linting adding import adding factory default configs to import remove some dependencies from config removing more dependencies actually test different versions updating testing procs updating robofile reformatting RoboFile codacy config removing unnecessary steps updating testing Adding codacy to gitattributes Back to 8.1 requirement and deprecating quay Add phpcs to .gitattributes composer update restoring quay restoring quay reverting change --- .codacy.yml | 5 + .gitattributes | 2 + .github/workflows/ci.yml | 23 +- CHANGELOG.txt | 7 + RoboFile.php | 620 +++++++++--------- composer.json | 9 +- config/install/search_api.index.primary.yml | 102 +++ .../search_api.server.pantheon_search.yml | 43 ++ .../search_api_pantheon_admin.info.yml | 2 +- .../search_api_pantheon_examples.info.yml | 2 +- search_api_pantheon.info.yml | 2 +- src/Commands/Reload.php | 1 - src/Commands/Schema.php | 1 - src/Services/PantheonGuzzle.php | 27 +- src/Services/SolariumClient.php | 21 +- 15 files changed, 521 insertions(+), 346 deletions(-) create mode 100644 .codacy.yml create mode 100644 config/install/search_api.index.primary.yml create mode 100644 config/install/search_api.server.pantheon_search.yml diff --git a/.codacy.yml b/.codacy.yml new file mode 100644 index 00000000..9ac9391d --- /dev/null +++ b/.codacy.yml @@ -0,0 +1,5 @@ +--- +exclude_paths: + - RoboFile.php + - .github/workflows/ci.yml + - .github/workflows/create-branch-on-tag.yml \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 9c620965..d8330229 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,5 @@ /circle.yml export-ignore /.gitattributes export-ignore /.gitignore export-ignore +/codacy.yml export-ignore +/phpcs.xml export-ignore \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cc899d9..04619f27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: linting: runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 + image: quay.io/pantheon-public/build-tools-ci:v8.2 options: --user root name: Code linting env: @@ -30,6 +30,7 @@ jobs: SANDBOX_SSH_KEY: ${{ secrets.SANDBOX_SSH_KEY }} BASH_ENV: ~/.bashrc steps: + - name: Checkout uses: actions/checkout@v2 @@ -38,14 +39,19 @@ jobs: - name: Code sniff run: composer run-script code:lint + phpcompatibility: runs-on: ubuntu-latest + container: + image: quay.io/pantheon-public/build-tools-ci:v8.2 name: PHP Compatibility steps: + - name: PHPCompatibility uses: pantheon-systems/phpcompatibility-action@v1 with: - test-versions: 8.2 + test-versions: [8.1, 8.2, 8.3, 8.4] + build_test: strategy: matrix: @@ -53,7 +59,7 @@ jobs: fail-fast: false runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 + image: quay.io/pantheon-public/build-tools-ci:8.x-php8.1 options: --user root name: Build and test (Drupal ${{ matrix.drupal-version }}) env: @@ -70,9 +76,16 @@ jobs: BASH_ENV: ~/.bashrc DRUPAL_VERSION: ${{ matrix.drupal-version }} steps: + - name: Checkout uses: actions/checkout@v2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + ini-values: post_max_size=256M, max_execution_time=120 + - name: Login run: | git config --global user.email "$GIT_EMAIL" @@ -106,6 +119,7 @@ jobs: if: ${{ always() }} run: | ./vendor/bin/robo test:delete-sites + mirror_do: runs-on: ubuntu-latest name: Checkout & push to remote @@ -116,16 +130,19 @@ jobs: WORKSPACE: ${{ github.workspace }} DRUPAL_ORG_REMOTE: ${{ secrets.DRUPAL_ORG_REMOTE }} steps: + - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Install SSH key uses: shimataro/ssh-key-action@v2 with: key: ${{ secrets.SSH_KEY }} known_hosts: ${{ secrets.KNOWN_HOSTS }} if_key_exists: ignore + - name: Pushes to drupal.org repository run: | cd $WORKSPACE diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f80bc9cd..9c9eff16 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,10 @@ +Search API Patheon 8.3.0 +-------------------------------------------------- +- Compatible with Pantheon Search (Solr 8) +- Compatible with Drupal 10.x +- Versions of Drupal less than 10 are not supported. +- Versions of PHP less than 8.1 are not supported + Search API Patheon 8.x-8.x-alpha1 -------------------------------------------------- - Compatible with Pantheon Search (Solr 8) diff --git a/RoboFile.php b/RoboFile.php index b953004d..40c252ae 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -12,6 +12,9 @@ use Robo\Tasks; use Symfony\Component\Process\Process; use Symfony\Component\Yaml\Yaml; +use Symfony\Component\Finder\Finder; + +define('STATUS_JQ_FILTER', 'jq -r \'.pantheon_search.status\''); /** * RoboFile is the main entry point for Robo commands. @@ -30,12 +33,77 @@ class RoboFile extends Tasks { */ public DateTime $started; + public array $search_index; + public array $search_server; + /** * Class constructor. */ public function __construct() { $this->started = new DateTime(); require_once 'vendor/autoload.php'; + $this->getInstallConfigs(); + } + + public function test() { + $this->output()->writeln('RoboFile constructor: ' . $this->started->format('Y-m-d H:i:s')); + $this->output()->writeln('Search index: ' . print_r($this->search_index, TRUE)); + $this->output()->writeln('Search server: ' . print_r($this->search_server, TRUE)); + $this->output()->writeln('Hello world!'); + } + + public function getInstallConfigs(): void { + $finder = new Finder(); + try { + $finder->files() + ->in('./config/install') + ->name(['*.yml', '*.yaml']) + ->sortByName(); + if (!$finder->hasResults()) { + throw new \RuntimeException( + 'No YAML files found in the specified directory.' + ); + } + + foreach ($finder as $file) { + $filePath = $file->getRealPath(); + $fileName = $file->getBasename('.yml'); + + // Remove .yaml extension if present + $fileName = str_replace('.yaml', '', $fileName); + + try { + switch (substr($fileName, 0, 16)) { + case 'search_api.index': + $this->search_index = Yaml::parseFile($filePath); + break; + case 'search_api.serve': + $this->search_server = Yaml::parseFile($filePath); + break; + default: + break; + } + } + catch (\Exception $e) { + throw new \RuntimeException( + sprintf( + 'Error parsing YAML file %s: %s', + $filePath, + $e->getMessage() + ) + ); + } + } + } + catch (\Exception $e) { + throw new \RuntimeException( + sprintf( + 'Error accessing directory %s: %s', + $directoryPath, + $e->getMessage() + ) + ); + } } /** @@ -58,7 +126,7 @@ public function testDeleteSites() { /** * Run the full test suite for this project. */ - public function testFull(int $drupal_version = 9, string $site_name = NULL) { + public function testFull(int $drupal_version = 10, string $site_name = NULL) { // Get the right constraint based on current branch/tag. $constraint = $this->getCurrentConstraint(); // Ensure terminus 3 is installed. @@ -72,9 +140,10 @@ public function testFull(int $drupal_version = 9, string $site_name = NULL) { $site_name = substr(\uniqid('test-'), 0, 12); if ($_SERVER['GITHUB_RUN_NUMBER']) { // Ensure that 2 almost parallel runs do not collide. - $site_name .= '-' . $drupal_version . '-'. $_SERVER['GITHUB_RUN_NUMBER']; + $site_name .= '-' . $drupal_version . '-' . $_SERVER['GITHUB_RUN_NUMBER']; } } + $options['drupal_version'] = $drupal_version; // Create site, set connection mode to git and clone it to local. $this->testCreateSite($site_name, $options); @@ -83,12 +152,6 @@ public function testFull(int $drupal_version = 9, string $site_name = NULL) { $this->testAllowPlugins($site_name, $drupal_version); $this->testPhpVersion($site_name, $drupal_version); - // If received Drupal 10, upgrade the recently created site to Drupal 10. - if ($drupal_version === 10) { - // @todo Make it downgrade to Drupal 9 when Drupal 10 becomes the default version. - $this->testUpgradeToDrupal10($site_name); - } - // Composer require the corresponding modules, push to Pantheon and install the site. $this->testRequireSolr($site_name, $constraint); $this->testGitPush($site_name); @@ -113,36 +176,35 @@ public function testFull(int $drupal_version = 9, string $site_name = NULL) { // Test all the Solr things. $this->testSolrEnabled($site_name); - - // Test creating Solr index. - $this->testSolrIndexCreate($site_name, 'dev'); - - // Test running the reload - $this->testPantheonSolrReload($site_name, 'dev'); - $this->testSolrReload($site_name, 'dev'); - // Test select query. $this->testSolrSelect($site_name, 'dev'); // Finally, run Solr diagnose. $this->testSolrDiagnose($site_name, 'dev'); - $this->output()->write( 'All done! 🎉' ); + $this->output()->write('All done! 🎉'); return ResultData::EXITCODE_OK; } /** - * Get current composer constraint depending on whether we're on a tag, a branch or a PR. + * Get current composer constraint depending on whether we're on a tag, a + * branch or a PR. */ protected function getCurrentConstraint(): string { $branch = trim(shell_exec('git rev-parse --abbrev-ref HEAD')); if ($branch !== 'HEAD') { return "{$branch}-dev"; - } else { - $tag = trim(shell_exec('git describe --exact-match --tags $(git log -n1 --pretty=\'%h\')')); + } + else { + $tag = trim( + shell_exec( + 'git describe --exact-match --tags $(git log -n1 --pretty=\'%h\')' + ) + ); if ($tag) { return $tag; - } else { + } + else { // Maybe we are on a PR. $branch = $_SERVER['GITHUB_HEAD_REF']; $branch_parts = explode('/', $branch); @@ -157,16 +219,21 @@ protected function getCurrentConstraint(): string { } /** - * Ensure terminus 3 is installed, otherwise offer installing it using Homebrew. + * Ensure terminus 3 is installed, otherwise offer installing it using + * Homebrew. */ public function testCheckT3() { - if (!file_exists(static::$TERMINUS_EXE) || !is_executable(static::$TERMINUS_EXE)) { + if (!file_exists(static::$TERMINUS_EXE) || !is_executable( + static::$TERMINUS_EXE + )) { $this->confirm( - 'This demo makes extensive use of the Terminus 3 phar. Can I install it for you using homebrew?' - ); - $result = $this->taskExec('brew install pantheon-systems/external/terminus')->run(); + 'This demo makes extensive use of the Terminus 3 phar. Can I install it for you using homebrew?' + ); + $result = $this->taskExec( + 'brew install pantheon-systems/external/terminus' + )->run(); if (!$result->wasSuccessful()) { - exit(1); + exit(ResultData::EXITCODE_ERROR); } // @todo check for build tools plugin "wait" command. } @@ -177,17 +244,25 @@ public function testCheckT3() { * Create site in Pantheon if it doesn't exist. Return site info. * * @param string $site_name - * The machine name of the site to create. + * The machine name of the site to create. * * @return \Robo\Result */ - public function testCreateSite(string $site_name, array $options = ['org' => NULL]) { + public function testCreateSite( + string $site_name, + array $options = ['org' => NULL] + ) { $site_info = $this->siteInfo($site_name); if (empty($site_info)) { $home = $_SERVER['HOME']; $toReturn = $this->taskExec(static::$TERMINUS_EXE) - ->args('site:create', $site_name, $site_name, 'drupal-composer-managed'); - if ( !empty( $options['org'] ) ) { + ->args( + 'site:create', + $site_name, + $site_name, + sprintf('drupal-%d-composer-managed', $options['drupal_version']) + ); + if (!empty($options['org'])) { $toReturn->option('org', $options['org']); } $toReturn->run(); @@ -205,24 +280,24 @@ public function testCreateSite(string $site_name, array $options = ['org' => NUL * @param string $site_name */ public function waitForWorkflow(string $site_name, string $env = 'dev') { - $this->output()->write('Checking workflow status', true); + $this->output()->write('Checking workflow status', TRUE); exec( "terminus workflow:info:status $site_name.$env", $info ); - $info = $this->cleanUpInfo( $info ); - $this->output()->write( $info['workflow'], true ); + $info = $this->cleanUpInfo($info); + $this->output()->write($info['workflow'], TRUE); // Wait for workflow to finish only if it hasn't already. This prevents the workflow:wait command from unnecessarily running for 260 seconds when there's no workflow in progress. - if ( $info['status'] !== 'succeeded' ) { - $this->output()->write('Waiting for platform', true); + if ($info['status'] !== 'succeeded') { + $this->output()->write('Waiting for platform', TRUE); exec( - "terminus build:workflow:wait --max=260 $site_name.$env", - $finished, - $status - ); + "terminus build:workflow:wait --max=260 $site_name.$env", + $finished, + $status + ); } if ($this->output()->isVerbose()) { @@ -232,30 +307,32 @@ public function waitForWorkflow(string $site_name, string $env = 'dev') { } /** - * Takes the output from a workflow:info:status command and converts it into a human-readable and easily parseable array. + * Takes the output from a workflow:info:status command and converts it into + * a human-readable and easily parseable array. * - * @param array $info Raw output from 'terminus workflow:info:status' + * @param array $info + * Raw output from 'terminus workflow:info:status' * * @return array An array of workflow status info. */ - private function cleanUpInfo( array $info ) : array { + private function cleanUpInfo(array $info): array { // Clean up the workflow status data and assign values to an array so it's easier to check. foreach ($info as $line => $value) { - $ln = array_values( array_filter( explode( " ", trim( $value ) ) ) ); + $ln = array_values(array_filter(explode(" ", trim($value)))); // Skip lines with only one value. This filters out the ASCII dividers output by the command. - if ( count( $ln ) > 1 ) { - if ( in_array( $ln[0], [ 'Started At', 'Finished At' ] ) ) { - $ln[0] = trim( str_replace( 'At', '', $ln[0] ) ); + if (count($ln) > 1) { + if (in_array($ln[0], ['Started At', 'Finished At'])) { + $ln[0] = trim(str_replace('At', '', $ln[0])); // Convert times to unix timestamps for easier use later. - $ln[1] = strtotime( $ln[1] ); + $ln[1] = strtotime($ln[1]); } - $info[ str_replace( ' ', '-', strtolower( $ln[0] ) ) ] = trim( $ln[1] ); + $info[str_replace(' ', '-', strtolower($ln[0]))] = trim($ln[1]); } // Remove the processed line. - unset( $info[ $line ] ); + unset($info[$line]); } return $info; @@ -285,7 +362,11 @@ public function setSiteSearch(string $site_name, $value = 'enable') { * @param string $connection * The connection mode to set (git/sftp). */ - public function testConnectionGit(string $site_name, string $env = 'dev', string $connection = 'git') { + public function testConnectionGit( + string $site_name, + string $env = 'dev', + string $connection = 'git' + ) { $this->taskExec('terminus') ->args('connection:set', $site_name . '.' . $env, $connection) ->run(); @@ -343,106 +424,6 @@ public function testAllowPlugins(string $site_name, int $drupal_version) { } } - /** - * Upgrade given site to Drupal 10. - * - * @param string $site_name - * The machine name of the site to downgrade. - */ - public function testUpgradeToDrupal10(string $site_name) { - $site_folder = $this->getSiteFolder($site_name); - chdir($site_folder); - - // Remove composer lock. - $this->taskExec('rm') - ->args('composer.lock') - ->run(); - - $this->taskExec('composer') - ->args( - 'config', - 'minimum-stability', - 'dev' - ) - ->run(); - - $this->taskExec('composer') - ->args( - 'config', - 'platform.php', - '8.1' - ) - ->run(); - - $this->taskExec('composer') - ->args( - 'require', - '--no-update', - 'drupal/core-recommended:^10', - 'drupal/core-project-message:^10', - 'drupal/core-composer-scaffold:^10', - 'pantheon-systems/drupal-integrations:^10', - 'mglaman/composer-drupal-lenient' - ) - ->run(); - - $this->taskExec('composer') - ->args( - 'require', - '--no-update', - '--dev', - 'drupal/core-dev:^10' - ) - ->run(); - - $this->taskExec('composer') - ->args('update') - ->run(); - - $this->taskExec('composer') - ->args( - 'config', - '--merge', - '--json', - 'extra.drupal-lenient.allowed-list', - '["drupal/search_api_pantheon"]' - ) - ->run(); - return ResultData::EXITCODE_OK; - } - - /** - * Downgrade given site to Drupal 8. - * - * @param string $site_name - * The machine name of the site to downgrade. - */ - public function testDowngradeToDrupal8(string $site_name) { - $site_folder = $this->getSiteFolder($site_name); - chdir($site_folder); - - // Remove composer lock. - $this->taskExec('rm') - ->args('composer.lock') - ->run(); - - - $this->taskExec('composer') - ->args( - 'require', - '--no-update', - '-W', - 'drupal/core-recommended:^8', - 'pantheon-systems/drupal-integrations:^8' - ) - ->run(); - - $this->taskExec('composer') - ->args('update') - ->run(); - return ResultData::EXITCODE_OK; - } - /** * Composer require the Solr related modules. * @@ -451,7 +432,10 @@ public function testDowngradeToDrupal8(string $site_name) { * @param string $constraint * The constraint to use for the search_api_pantheon module. */ - public function testRequireSolr(string $site_name, string $constraint = '^8') { + public function testRequireSolr( + string $site_name, + string $constraint = '^8' + ) { $site_folder = $this->getSiteFolder($site_name); chdir($site_folder); // Always test again latest version of search_api_solr. @@ -491,7 +475,10 @@ protected function getSiteFolder(string $site_name) { * @param string $commit_msg * The commit message to use. */ - public function testGitPush(string $site_name, string $commit_msg = 'Changes committed from demo script.') { + public function testGitPush( + string $site_name, + string $commit_msg = 'Changes committed from demo script.' + ) { $site_folder = $this->getSiteFolder($site_name); chdir($site_folder); try { @@ -530,13 +517,24 @@ public function testGitPush(string $site_name, string $commit_msg = 'Changes com * @param string $profile * The Drupal profile to use during site installation. */ - public function testSiteInstall(string $site_name, string $env = 'dev', string $profile = 'demo_umami') { + public function testSiteInstall( + string $site_name, + string $env = 'dev', + string $profile = 'demo_umami' + ) { $this->taskExec(static::$TERMINUS_EXE) - ->args('drush', $site_name . '.' . $env, '--', 'site:install', $profile, '-y') + ->args( + 'drush', + $site_name . '.' . $env, + '--', + 'site:install', + $profile, + '-y' + ) ->options([ 'account-name' => 'admin', - 'site-name' => $site_name, - 'locale' => 'en', + 'site-name' => $site_name, + 'locale' => 'en', ]) ->run(); $this->waitForWorkflow($site_name); @@ -554,55 +552,56 @@ public function testSiteInstall(string $site_name, string $env = 'dev', string $ public function testModuleEnable(string $site_name, string $env = 'dev') { $this->taskExec(static::$TERMINUS_EXE) ->args( - 'drush', - $site_name . '.' . $env, - 'cr' - ) + 'drush', + $site_name . '.' . $env, + 'cr' + ) ->run(); $this->taskExec(static::$TERMINUS_EXE) ->args( - 'drush', - $site_name . '.' . $env, - 'pm-uninstall', - 'search', - ) + 'drush', + $site_name . '.' . $env, + 'pm-uninstall', + 'search', + ) ->run(); $this->waitForWorkflow($site_name); $this->taskExec(static::$TERMINUS_EXE) ->args( - 'drush', - $site_name . '.' . $env, - '--', - 'pm-enable', - '--yes', - 'search_api_pantheon', - 'search_api_pantheon_admin', - 'search_api_solr_admin' - ) + 'drush', + $site_name . '.' . $env, + '--', + 'pm-enable', + '--yes', + 'search_api_pantheon', + 'search_api_pantheon_admin', + 'search_api_solr_admin' + ) ->run(); $this->taskExec(static::$TERMINUS_EXE) ->args( - 'drush', - $site_name . '.' . $env, - 'cr' - ) + 'drush', + $site_name . '.' . $env, + 'cr' + ) ->run(); } + /** - * Run through various diagnostics to ensure that Solr8 is enabled and working. + * Run through various diagnostics to ensure that Solr8 is enabled and + * working and an index has been created. * * @param string $site_name * The machine name of the site to run the diagnostics on. * @param string $env * The environment to run the diagnostics on. */ - public function testSolrEnabled( string $site_name, string $env = 'dev' ) { - + public function testSolrEnabled(string $site_name, string $env = 'dev') { try { // Attempt to ping the Pantheon Solr server. - $this->output()->write('Attempting to ping the Solr server...', true); - $ping = $this->taskExec( static::$TERMINUS_EXE ) + $this->output()->write('Attempting to ping the Solr server...', TRUE); + $ping = $this->taskExec(static::$TERMINUS_EXE) ->args( 'drush', "$site_name.$env", @@ -611,33 +610,50 @@ public function testSolrEnabled( string $site_name, string $env = 'dev' ) { ) ->run(); - if ( $ping instanceof Result && ! $ping->wasSuccessful() ) { - \Kint::dump( $ping ); - throw new \Exception( 'An error occurred attempting to ping Solr server' ); - } + if ($ping instanceof Result && !$ping->wasSuccessful()) { + \Kint::dump($ping); + throw new \Exception( + 'An error occurred attempting to ping Solr server' + ); + } - // Check that Solr8 is enabled. - $this->output()->write('Checking for Solr8 search API server...', true); - exec( - "terminus remote:drush $site_name.$env -- search-api-server-list | grep pantheon_solr8", - $server_list + // Check that Solr8 is enabled. + $this->output()->write('Checking for Solr8 search API server...', TRUE); + exec( + "terminus remote:drush $site_name.$env -- search-api-server-list --format=json | " . STATUS_JQ_FILTER, + $server_list, + ); + if (empty($server_list)) { + \Kint::dump($server_list); + throw new \Exception( + 'No Servers Available. The default server was not imported when the module was enabled.' + ); + } + if (stripos($server_list, 'enabled') === FALSE) { + \Kint::dump($server_list); + throw new \Exception( + 'An error occurred checking that Solr8 was enabled: ' . print_r( + $server_list, + TRUE + ) ); + } - if ( stripos( $server_list[0], 'enabled' ) === false ) { - \Kint::dump( $server_list ); - throw new \Exception( 'An error occurred checking that Solr8 was enable.d' ); - } } catch (\Exception $e) { + $this->output()->write($e->getMessage()); return ResultData::EXITCODE_ERROR; + } + catch (\Throwable $t) { $this->output()->write($t->getMessage()); return ResultData::EXITCODE_ERROR; } + $this->output()->write('👍👍👍 Solr8 is enabled and working.', TRUE); return ResultData::EXITCODE_OK; } @@ -649,23 +665,25 @@ public function testSolrEnabled( string $site_name, string $env = 'dev' ) { * @param string $env * The environment to run the diagnostics on. */ - public function testSolrDiagnose( string $site_name, string $env = 'dev' ) { + public function testSolrDiagnose(string $site_name, string $env = 'dev') { try { // Run a diagnose command to make sure everything is okay. - $this->output()->write('Running search-api-pantheon:diagnose...', true); - $diagnose = $this->taskExec( static::$TERMINUS_EXE ) + $this->output()->write('Running search-api-pantheon:diagnose...', TRUE); + $diagnose = $this->taskExec(static::$TERMINUS_EXE) ->args( - 'drush', - "$site_name.$env", - '--', - 'search-api-pantheon:diagnose', - '-v' + 'drush', + "$site_name.$env", + '--', + 'search-api-pantheon:diagnose', + '-v' ) ->run(); - if ( $diagnose instanceof Result && ! $diagnose->wasSuccessful() ) { - \Kint::dump( $diagnose ); - throw new \Exception( 'An error occurred while running Solr search diagnostics.' ); + if ($diagnose instanceof Result && !$diagnose->wasSuccessful()) { + \Kint::dump($diagnose); + throw new \Exception( + 'An error occurred while running Solr search diagnostics.' + ); } } catch (\Exception $e) { @@ -685,10 +703,10 @@ public function testSolrDiagnose( string $site_name, string $env = 'dev' ) { */ public function demoLoginBrowser(string $site_name, string $env = 'dev') { exec( - 'terminus drush ' . $site_name . '.' . $env . ' -- uli admin', - $finished, - $status - ); + 'terminus drush ' . $site_name . '.' . $env . ' -- uli admin', + $finished, + $status + ); $finished = trim(join('', $finished)); $this->output()->writeln($finished); $this->_exec('open ' . $finished); @@ -701,15 +719,15 @@ protected function say($text, string $step_id = 'narration') { $now = new \DateTime(); $filename = 'narration-' . - $now->diff($this->started)->format('%I-%S-%F') . '-' . $step_id . '.m4a'; + $now->diff($this->started)->format('%I-%S-%F') . '-' . $step_id . '.m4a'; $this->output->writeln('/Users/Shared/' . $filename); return (new Process([ - '/usr/bin/say', - '--voice=Daniel', - "--output-file={$filename}", - '--file-format=m4af', - $text, - ], '/Users/Shared')) + '/usr/bin/say', + '--voice=Daniel', + "--output-file={$filename}", + '--file-format=m4af', + $text, + ], '/Users/Shared')) ->enableOutput() ->setTty(TRUE); } @@ -724,7 +742,11 @@ protected function say($text, string $step_id = 'narration') { */ protected function siteInfo(string $site_name) { try { - exec(static::$TERMINUS_EXE . ' site:info --format=json ' . $site_name, $output, $status); + exec( + static::$TERMINUS_EXE . ' site:info --format=json ' . $site_name, + $output, + $status + ); if (!empty($output)) { $result = json_decode(join("", $output), TRUE, 512, JSON_THROW_ON_ERROR); return $result; @@ -748,8 +770,9 @@ public function testPhpVersion(string $site_name, int $drupal_version) { $pantheon_yml_contents = Yaml::parseFile($site_folder . '/pantheon.yml'); if ($drupal_version === 10) { $pantheon_yml_contents['php_version'] = 8.2; - } else { - $pantheon_yml_contents['php_version'] = 8.1; + } + else { + $pantheon_yml_contents['php_version'] = 8.3; } $pantheon_yml_contents = Yaml::dump($pantheon_yml_contents); file_put_contents($site_folder . '/pantheon.yml', $pantheon_yml_contents); @@ -780,70 +803,25 @@ public function testEnvSolr(string $site_name) { * The environment to create the index in. */ public function testSolrIndexCreate(string $site_name, string $env = 'dev') { - $result = $this->taskExec( static::$TERMINUS_EXE ) - ->args( - 'drush', - "$site_name.$env", - '--', - 'cim', - '--partial', - '--source=modules/contrib/search_api_pantheon/.ci/config', - '-y' - ) - ->run(); - if (!$result->wasSuccessful()) { - exit(1); - } - // Index new solr. - $result = $this->taskExec( static::$TERMINUS_EXE ) - ->args( - 'drush', - "$site_name.$env", - '--', - 'sapi-i' - ) - ->run(); - if (!$result->wasSuccessful()) { - exit(1); - } - } - public function testPantheonSolrReload(string $site_name, string $env = 'dev') { - $result = $this->taskExec( static::$TERMINUS_EXE ) - ->args( - 'drush', - "$site_name.$env", - '--', - 'search-api-pantheon:reloadSchema', - ) - ->run(); - if (!$result->wasSuccessful()) { - exit(1); - } - } - - public function testSolrReload(string $site_name, string $env = 'dev') { - $result = $this->taskExec( static::$TERMINUS_EXE ) - ->args( - 'drush', - "$site_name.$env", - '--', - 'search-api-solr:reload', - 'pantheon_solr8' - ) - ->run(); - if (!$result->wasSuccessful()) { - exit(1); - } + // Index new solr. + $result = $this->taskExec(static::$TERMINUS_EXE) + ->args( + 'drush', + "$site_name.$env", + '--', + 'sapi-i' + ) + ->run(); + if (!$result->wasSuccessful()) { + exit(1); + } } - - - - /** - * Use search-api-pantheon:select command to ensure both Drupal index and the actual Solr index have the same amount of items. + * Use search-api-pantheon:select command to ensure both Drupal index and the + * actual Solr index have the same amount of items. * * @param string $site_name * The machine name of the site to run the tests on. @@ -851,51 +829,53 @@ public function testSolrReload(string $site_name, string $env = 'dev') { * The environment to run the tests on. */ public function testSolrSelect(string $site_name, string $env = 'dev') { - $sapi_s = new Process([ - static::$TERMINUS_EXE, - 'drush', - "$site_name.$env", - '--', - 'sapi-s', - '--field=Indexed', - ]); - $total_indexed = 0; - $sapi_s->run(); - if ($sapi_s->isSuccessful()) { - $result = $sapi_s->getOutput(); - $result_parts = explode("\n", $result); - foreach ($result_parts as $part) { - if (is_numeric(trim($part))) { - $total_indexed = trim($part); - } + $sapi_s = new Process([ + static::$TERMINUS_EXE, + 'drush', + "$site_name.$env", + '--', + 'sapi-s', + '--field=Indexed', + ]); + $total_indexed = 0; + $sapi_s->run(); + if ($sapi_s->isSuccessful()) { + $result = $sapi_s->getOutput(); + $result_parts = explode("\n", $result); + foreach ($result_parts as $part) { + if (is_numeric(trim($part))) { + $total_indexed = trim($part); } } + } - $saps = new Process([ - static::$TERMINUS_EXE, - 'drush', - "$site_name.$env", - '--', - 'saps', - '*:*' - ]); - $num_found = 0; - $saps->run(); - if ($saps->isSuccessful()) { - $result = $saps->getOutput(); - $result_parts = explode("\n", $result); - foreach ($result_parts as $part) { - if (strpos($part, 'numFound') !== FALSE) { - $num_found = trim(str_replace('"numFound":', '', $part), ' ,'); - break; - } + $saps = new Process([ + static::$TERMINUS_EXE, + 'drush', + "$site_name.$env", + '--', + 'saps', + '*:*', + ]); + $num_found = 0; + $saps->run(); + if ($saps->isSuccessful()) { + $result = $saps->getOutput(); + $result_parts = explode("\n", $result); + foreach ($result_parts as $part) { + if (strpos($part, 'numFound') !== FALSE) { + $num_found = trim(str_replace('"numFound":', '', $part), ' ,'); + break; } } + } - if ($total_indexed && $num_found && $total_indexed != $num_found) { - $this->output->writeln('Solr indexing error. Total indexed: ' . $total_indexed . ' but found: ' . $num_found); - exit(1); - } + if ($total_indexed && $num_found && $total_indexed != $num_found) { + $this->output->writeln( + 'Solr indexing error. Total indexed: ' . $total_indexed . ' but found: ' . $num_found + ); + exit(1); + } } } diff --git a/composer.json b/composer.json index ced543bd..5690c5b6 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "preferred-install": "dist", "sort-packages": true, "platform": { - "php": "8.2" + "php": "8.1" }, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true @@ -37,7 +37,7 @@ } }, "require": { - "php": ">=8.2", + "php": ">=8.1", "ext-curl": "*", "ext-json": "*", "ext-zip": "*", @@ -45,12 +45,13 @@ "guzzlehttp/guzzle": "^7.5", "guzzlehttp/psr7": "^2.7", "kint-php/kint": "^5|^6", + "php-http/guzzle7-adapter": "^1.1", "psr/event-dispatcher": "^1.0", "symfony/finder": "^4.4|^5|^6|^7", "symfony/yaml": "^4.4|^5|^6|^7" }, "require-dev": { - "consolidation/robo": "^4", + "consolidation/robo": "^3 || ^4 || ^5", "czproject/git-php": "^4.0", "drupal/coder": "@stable", "phpunit/phpunit": "@stable", @@ -70,7 +71,7 @@ ], "code:fix": [ "vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer", - "vendor/bin/phpcbf . --ignore=RoboFile.php,vendor src modules" + "vendor/bin/phpcbf . --ignore=vendor src modules" ], "code:lint": [ "vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer", diff --git a/config/install/search_api.index.primary.yml b/config/install/search_api.index.primary.yml new file mode 100644 index 00000000..934ed0a2 --- /dev/null +++ b/config/install/search_api.index.primary.yml @@ -0,0 +1,102 @@ +langcode: en +status: true +dependencies: + module: + - node + - search_api_solr +third_party_settings: + search_api_solr: + finalize: false + commit_before_finalize: false + commit_after_finalize: false + debug_finalize: false + highlighter: + maxAnalyzedChars: 51200 + fragmenter: gap + usePhraseHighlighter: true + highlightMultiTerm: true + preserveMulti: false + regex: + slop: 0.5 + pattern: blank + maxAnalyzedChars: 10000 + highlight: + mergeContiguous: false + requireFieldMatch: false + snippets: 3 + fragsize: 0 + mlt: + mintf: 1 + mindf: 1 + maxdf: 0 + maxdfpct: 0 + minwl: 0 + maxwl: 0 + maxqt: 100 + maxntp: 2000 + boost: false + interestingTerms: none + term_modifiers: + slop: 3 + fuzzy: 1 + fuzzy_analyzer: true + advanced: + index_prefix: '' + collection: '' + timezone: '' + multilingual: + limit_to_content_language: false + include_language_independent: true + use_language_undefined_as_fallback_language: false + specific_languages: + en: '0' + use_universal_collation: false +id: primary +name: primary +description: '' +read_only: false +field_settings: { } +datasource_settings: + 'entity:node': + bundles: + default: true + selected: { } + languages: + default: true + selected: { } +processor_settings: + add_url: { } + aggregated_field: { } + auto_aggregated_fulltext_field: { } + custom_value: { } + entity_type: { } + highlight: + weights: + postprocess_query: 0 + prefix: '' + suffix: '' + excerpt: true + excerpt_always: false + excerpt_length: 256 + exclude_fields: { } + highlight: always + highlight_partial: false + language_with_fallback: { } + rendered_item: { } + reverse_entity_references: { } + solr_boost_more_recent: + weights: + preprocess_query: 0 + boosts: { } + solr_date_range: + weights: + preprocess_index: 0 +tracker_settings: + default: + indexing_order: fifo +options: + cron_limit: 50 + delete_on_fail: true + index_directly: true + track_changes_in_references: true +server: pantheon_search diff --git a/config/install/search_api.server.pantheon_search.yml b/config/install/search_api.server.pantheon_search.yml new file mode 100644 index 00000000..9b2839b2 --- /dev/null +++ b/config/install/search_api.server.pantheon_search.yml @@ -0,0 +1,43 @@ +langcode: en +status: true +dependencies: + module: + - search_api_pantheon + - search_api_solr +id: pantheon_search +name: 'Pantheon Search' +description: 'Default search server for Pantheon Search.' +backend: search_api_solr +backend_config: + retrieve_data: false + highlight_data: false + site_hash: false + server_prefix: '' + domain: generic + environment: default + connector: pantheon + connector_config: + scheme: https + port: 443 + path: v1 + timeout: 5 + index_timeout: 5 + optimize_timeout: 10 + finalize_timeout: 30 + solr_version: '8' + http_method: AUTO + commit_within: 1000 + jmx: false + jts: false + solr_install_dir: '' + skip_schema_check: true + optimize: false + fallback_multiple: false + disabled_field_types: { } + disabled_caches: { } + disabled_request_handlers: + disabled_request_dispatchers: + rows: 10 + index_single_documents_fallback_count: 10 + index_empty_text_fields: false + suppress_missing_languages: false diff --git a/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml b/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml index caeff4b1..91b07f4b 100644 --- a/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml +++ b/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon Admin type: module description: Administer a Pantheon Search server -core_version_requirement: ^9.4 || ^10 || ^11 +core_version_requirement: ^10 || ^11 package: Search dependencies: - search_api_solr:search_api_solr diff --git a/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml b/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml index 62efa38a..7d5d1e33 100644 --- a/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml +++ b/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon Examples type: module description: Contains some examples of things you could do with Search API Pantheon module. This module should not be enabled in prod. -core_version_requirement: ^9.4 || ^10 || ^11 +core_version_requirement: ^10 || ^11 package: Search dependencies: - search_api_pantheon:search_api_pantheon diff --git a/search_api_pantheon.info.yml b/search_api_pantheon.info.yml index f0bb27b8..6b4e328b 100644 --- a/search_api_pantheon.info.yml +++ b/search_api_pantheon.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon type: module description: Search API + Solr + Pantheon integration -core_version_requirement: ^9.4 || ^10 || ^11 +core_version_requirement: ^10 || ^11 package: Search dependencies: - search_api_solr:search_api_solr diff --git a/src/Commands/Reload.php b/src/Commands/Reload.php index 52fad527..45070a78 100644 --- a/src/Commands/Reload.php +++ b/src/Commands/Reload.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelTrait; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SchemaPoster; use Drush\Commands\DrushCommands; diff --git a/src/Commands/Schema.php b/src/Commands/Schema.php index e9e605e1..85718826 100644 --- a/src/Commands/Schema.php +++ b/src/Commands/Schema.php @@ -2,7 +2,6 @@ namespace Drupal\search_api_pantheon\Commands; -use Drupal\Core\Logger\LoggerChannelTrait; use Drupal\search_api_pantheon\Plugin\SolrConnector\PantheonSolrConnector; use Drupal\search_api_pantheon\Services\PantheonGuzzle; use Drupal\search_api_pantheon\Services\SchemaPoster; diff --git a/src/Services/PantheonGuzzle.php b/src/Services/PantheonGuzzle.php index 3e4f4786..0d73b606 100644 --- a/src/Services/PantheonGuzzle.php +++ b/src/Services/PantheonGuzzle.php @@ -2,6 +2,7 @@ namespace Drupal\search_api_pantheon\Services; +use GuzzleHttp\Psr7\HttpFactory; use Drupal\search_api_pantheon\Traits\EndpointAwareTrait; use GuzzleHttp\Client; use GuzzleHttp\Handler\CurlHandler; @@ -13,8 +14,10 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Solarium\Core\Client\Adapter\AdapterInterface; +use Solarium\Core\Client\Adapter\Psr18Adapter; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Session\AccountProxyInterface; +use Solarium\Core\Client\Endpoint; /** * Pantheon-specific extension of the Guzzle http query class. @@ -23,8 +26,7 @@ */ class PantheonGuzzle extends Client implements ClientInterface, - LoggerAwareInterface, - AdapterInterface { + LoggerAwareInterface { use LoggerAwareTrait; use EndpointAwareTrait; @@ -38,7 +40,11 @@ class PantheonGuzzle extends Client implements /** * Class Constructor. */ - public function __construct(Endpoint $endpoint, LoggerChannelFactoryInterface $logger_factory, AccountProxyInterface $current_user) { + public function __construct( + Endpoint $endpoint, + LoggerChannelFactoryInterface $logger_factory, + AccountProxyInterface $current_user + ) { $stack = new HandlerStack(); $stack->setHandler(new CurlHandler()); $stack->push( @@ -160,4 +166,19 @@ public function requestUriAlterForPantheonEnvironment(RequestInterface $request) return $request->withUri($uri); } + /** + * Get a PSR adapter interface based on this class. + * + * @return \Solarium\Core\Client\Adapter\AdapterInterface + * The interface in question. + */ + public function getAdapter(): AdapterInterface { + $factory = new HttpFactory(); + return new Psr18Adapter( + $this, + $factory, + $factory, + ); + } + } diff --git a/src/Services/SolariumClient.php b/src/Services/SolariumClient.php index b0bfc3f6..038990a9 100644 --- a/src/Services/SolariumClient.php +++ b/src/Services/SolariumClient.php @@ -9,8 +9,7 @@ use Solarium\Core\Query\QueryInterface; use Solarium\Core\Query\Result\ResultInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; -use Drupal\search_api_pantheon\Solarium\EventDispatcher\Psr14Bridge; -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Customized Solrium Client to send Guzzle debugging to log entries. @@ -21,18 +20,18 @@ class SolariumClient extends Client { /** * Class constructor. */ - public function __construct(PantheonGuzzle $guzzle, Endpoint $endpoint, LoggerChannelFactoryInterface $logger_factory, EventDispatcher $event_dispatcher) { + public function __construct( + PantheonGuzzle $guzzle, + Endpoint $endpoint, + LoggerChannelFactoryInterface $logger_factory, + EventDispatcherInterface $event_dispatcher) { $drupal_major_parts = explode('.', \Drupal::VERSION); $drupal_major = reset($drupal_major_parts); - if ($drupal_major < 9) { - // Use the bridge only if Drupal 8. - $event_dispatcher = new Psr14Bridge($event_dispatcher); - } parent::__construct( - $guzzle, - $event_dispatcher, - ['endpoint' => [$endpoint]] - ); + $guzzle->getAdapter(), + $event_dispatcher, + ['endpoint' => [$endpoint]], + ); $this->logger = $logger_factory->get('PantheonSolariumClient'); $this->setDefaultEndpoint($endpoint); } From bde6d9b3380dbe152ddbf49a9001027076fc546a Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Tue, 28 Jan 2025 12:48:34 -0800 Subject: [PATCH 15/17] ci versions --- .github/workflows/ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04619f27..90183458 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: linting: runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:v8.2 + image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 options: --user root name: Code linting env: @@ -43,7 +43,7 @@ jobs: phpcompatibility: runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:v8.2 + image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 name: PHP Compatibility steps: @@ -59,7 +59,7 @@ jobs: fail-fast: false runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.1 + image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 options: --user root name: Build and test (Drupal ${{ matrix.drupal-version }}) env: @@ -80,12 +80,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.1 - ini-values: post_max_size=256M, max_execution_time=120 - - name: Login run: | git config --global user.email "$GIT_EMAIL" From 06398c257e5965f697ae3600b3cab68fd2147add Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Tue, 28 Jan 2025 12:50:16 -0800 Subject: [PATCH 16/17] revert to 8.1 --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90183458..5a3cd708 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: linting: runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 + image: quay.io/pantheon-public/build-tools-ci:8.x-php8.1 options: --user root name: Code linting env: @@ -42,8 +42,6 @@ jobs: phpcompatibility: runs-on: ubuntu-latest - container: - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 name: PHP Compatibility steps: @@ -59,7 +57,7 @@ jobs: fail-fast: false runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 + image: quay.io/pantheon-public/build-tools-ci:8.x-php8.1 options: --user root name: Build and test (Drupal ${{ matrix.drupal-version }}) env: From 43769bf71cccb642e1d9747fbd9fb26153dee07d Mon Sep 17 00:00:00 2001 From: Tom Stovall Date: Tue, 28 Jan 2025 12:52:32 -0800 Subject: [PATCH 17/17] only check syntax for 8.1 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a3cd708..15b86fd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: - name: PHPCompatibility uses: pantheon-systems/phpcompatibility-action@v1 with: - test-versions: [8.1, 8.2, 8.3, 8.4] + test-versions: 8.1 build_test: strategy: