From 356dae0b8a2030d97adaaaefed096633b8223e35 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Thu, 11 Jun 2026 11:14:25 +0100 Subject: [PATCH 01/17] Add install-solr script for ddev addon This script installs the ddev/ddev-solr addon, removes old configurations, and updates the Solr configuration to version 9. It also provides instructions for applying changes --- commands/host/install-solr | 115 +++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 commands/host/install-solr diff --git a/commands/host/install-solr b/commands/host/install-solr new file mode 100644 index 0000000..0f7d6a0 --- /dev/null +++ b/commands/host/install-solr @@ -0,0 +1,115 @@ +#!/usr/bin/env bash +#annertech-ddev + +## Description: Install ddev/ddev-solr addon +## Usage: install-solr +## Example: "ddev install-solr" + +set -e + +RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' +echo_red() { echo -e "${RED}$1${NC}" >&2; } +echo_green() { echo -e "${GREEN}$1${NC}"; } +echo_yellow() { echo -e "${YELLOW}$1${NC}"; } + +SERVICES_FILE=".platform/services.yaml" +SOLR_CONF_SOURCE="web/modules/contrib/search_api_solr/solr-conf-templates/9.x" + +echo_yellow "Installing ddev/ddev-solr addon..." + +remove_old_config() { + echo_yellow "Removing old ddev solr configuration..." + + if [ -f .ddev/docker-compose.solr.yaml ]; then + git rm .ddev/docker-compose.solr.yaml + else + echo_yellow "↳ .ddev/docker-compose.solr.yaml not found, skipping." + fi + + if [ -d .ddev/solr ]; then + git rm -rf .ddev/solr/ + else + echo_yellow "↳ .ddev/solr/ not found, skipping." + fi + + git commit -m "remove the ddev drupal solr" || echo_yellow "↳ Nothing to commit for old config removal." + echo_green "✓ Old ddev solr configuration removed." +} + +install_new_addon() { + echo_yellow "Installing ddev/ddev-solr..." + ddev add-on get ddev/ddev-solr + git add .ddev/ + git commit -m "install ddev/ddev-solr" + echo_green "✓ ddev/ddev-solr installed." +} + +configure_upsun() { + echo_yellow "Configuring upsun solr..." + + # Replace solr conf directory + if [ ! -d "$SOLR_CONF_SOURCE" ]; then + echo_red "✗ Solr config templates not found at $SOLR_CONF_SOURCE. Is search_api_solr installed?" + exit 1 + fi + + echo_yellow "↳ Removing old solr conf for upsun..." + if [ -d .platform/solr-conf/8.x ]; then + git rm -rf .platform/solr-conf/8.x + git commit -m "remove the old solr configuration" + else + echo_yellow "↳ .platform/solr-conf/8.x not found, skipping removal." + fi + + echo_yellow "↳ Copying new solr 9 configuration..." + cp -r "$SOLR_CONF_SOURCE" .platform/solr-conf + git add .platform/solr-conf + git commit -m "add new solr 9 configuration" + echo_green "✓ Old solr configuration replaced with solr 9 configuration." + + # Update services.yaml + if [ ! -f "$SERVICES_FILE" ]; then + echo_red "✗ File not found: $SERVICES_FILE" + exit 1 + fi + + echo_yellow "Updating $SERVICES_FILE..." + + # Solr version + if grep -q "solr:9.4" "$SERVICES_FILE"; then + echo_yellow "↳ Solr version already updated, skipping." + else + sed -i 's/type: solr:8\.0/type: solr:9.4/g' "$SERVICES_FILE" + echo_green "✓ solr 8.0 -> 9.4" + fi + + # Solr core name + if grep -q "maincore" "$SERVICES_FILE"; then + echo_yellow "↳ Solr core name already updated, skipping." + else + sed -i 's/solr8core/maincore/g' "$SERVICES_FILE" + echo_green "✓ solr8core -> maincore" + fi + + # Solr conf_dir + if grep -q "solr-conf/9.x" "$SERVICES_FILE"; then + echo_yellow "↳ Solr conf_dir already updated, skipping." + else + sed -i 's|conf_dir: !archive "solr-conf/8\.x"|conf_dir: !archive "solr-conf/9.x"|g' "$SERVICES_FILE" + echo_green "✓ solr-conf/8.x -> solr-conf/9.x" + fi + + echo "" + echo_yellow "Review changes with: 'git diff $SERVICES_FILE'" + echo_yellow "If changes look good, commit with: 'git commit $SERVICES_FILE -m \"update solr 8 to 9 configuration\"'" +} + +remove_old_config +install_new_addon +configure_upsun + +echo "" +echo_green "✓ ddev-solr installed successfully." +echo_yellow "↳ Run 'ddev restart' to apply changes." +echo_yellow "↳ After restart, run 'ddev solr9 -c' to configure Solr and rebuild the index." +echo_green "✓ Done. Solr will be available at: ${DDEV_PRIMARY_URL}:8983" From 1331a892fcb319008731d7a2df485d85ec141ac5 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Thu, 11 Jun 2026 10:17:51 +0000 Subject: [PATCH 02/17] Add helper to get solr9 up and running locally --- commands/host/solr9 | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 commands/host/solr9 diff --git a/commands/host/solr9 b/commands/host/solr9 new file mode 100644 index 0000000..7cca079 --- /dev/null +++ b/commands/host/solr9 @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +#annertech-ddev + +## Description: Install ddev/ddev-solr addon +## Usage: solr9 [-c] +## Example: "ddev solr9" +## Example: "ddev solr9 -c" +## Flags: [{"Name":"c","Usage":"Run Solr setup and configuration"}] + +RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' +echo_red() { echo -e "${RED}$1${NC}" >&2; } +echo_green() { echo -e "${GREEN}$1${NC}"; } +echo_yellow() { echo -e "${YELLOW}$1${NC}"; } + +SOLR_SERVER_NAME="solr" +SOLR_COLLECTION="collection_1" +RUN_SETUP=false + +# Optional setup argument +if [ "$1" = "-c" ] || [ "$1" = "c" ]; then + RUN_SETUP=true +fi + +echo_yellow "Configuring ddev/ddev-solr for local development" + +collection_exists() { + ddev solr status 2>/dev/null | grep -q "${SOLR_COLLECTION}" +} + +module_enabled() { + ddev drush pm:list --status=enabled --field=name 2>/dev/null | grep -q "search_api_solr_admin" +} + +configset_uploaded() { + ddev solr zk ls /configs 2>/dev/null | grep -q "${SOLR_COLLECTION}" +} + +configure_local_drupal_setup() { + if collection_exists; then + echo_yellow "↳ Collection '${SOLR_COLLECTION}' already exists, skipping creation." + else + echo_yellow "↳ Creating collection '${SOLR_COLLECTION}'..." + ddev solr create_collection --name=${SOLR_COLLECTION} + fi + + if module_enabled; then + echo_yellow "↳ Module 'search_api_solr_admin' already enabled, skipping." + else + echo_yellow "↳ Enabling search_api_solr_admin module..." + ddev drush en search_api_solr_admin -y + fi + + if configset_uploaded; then + echo_yellow "↳ Configset already uploaded, skipping." + else + echo_yellow "↳ Uploading configset..." + ddev drush --numShards=1 search-api-solr:upload-configset ${SOLR_SERVER_NAME} + fi +} + +rebuild_index() { + echo_yellow "↳ Rebuilding search index..." + ddev drush search-api:reset-tracker + ddev drush search-api:index +} + +if [ "$RUN_SETUP" = true ]; then + if ! configure_local_drupal_setup; then + echo_red "✗ Setup failed." + exit 1 + fi +fi + +if collection_exists; then + echo_yellow "Running search index rebuild..." + if ! rebuild_index; then + echo_red "✗ Index rebuild failed." + exit 1 + fi +else + echo_yellow "↳ No collection found, skipping index rebuild. Run with -c to configure." + exit 0 +fi + +echo_green "✓ Solr setup complete and search index rebuilt successfully." +echo_green "Visit ${DDEV_PRIMARY_URL}/admin/config/search/search-api/server/${SOLR_SERVER_NAME}" From dfc0c1154d63fd7f5431c3be9b4c29bbd4af878c Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Thu, 11 Jun 2026 10:20:01 +0000 Subject: [PATCH 03/17] Update settings override for solr local settings file --- settings.local.devmode.php | 7 +++++-- settings.local.perfmode.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/settings.local.devmode.php b/settings.local.devmode.php index a098c8c..0595c30 100644 --- a/settings.local.devmode.php +++ b/settings.local.devmode.php @@ -20,11 +20,14 @@ $config['stage_file_proxy.settings']['origin'] = getenv('STAGE_FILE_PROXY_URL'); // Override SOLR configuration for DDEV. -$config['search_api.server.solr']['backend_config']['connector_config']['scheme'] = 'http'; +$config['search_api.server.solr']['backend_config']['connector'] = 'solr_cloud_basic_auth'; +$config['search_api.server.solr']['backend_config']['connector_config']['username'] = 'solr'; +$config['search_api.server.solr']['backend_config']['connector_config']['password'] = 'SolrRocks'; $config['search_api.server.solr']['backend_config']['connector_config']['host'] = 'solr'; +$config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'collection_1'; $config['search_api.server.solr']['backend_config']['connector_config']['port'] = '8983'; $config['search_api.server.solr']['backend_config']['connector_config']['path'] = '/'; -$config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'dev'; +$config['search_api.server.solr']['backend_config']['connector_config']['scheme'] = 'http'; // Override SMTP configuration for DDEV. $config['smtp.settings']['smtp_host'] = 'localhost'; diff --git a/settings.local.perfmode.php b/settings.local.perfmode.php index 2bba02c..2e03465 100644 --- a/settings.local.perfmode.php +++ b/settings.local.perfmode.php @@ -20,11 +20,14 @@ $config['stage_file_proxy.settings']['origin'] = getenv('STAGE_FILE_PROXY_URL'); // Override SOLR configuration for DDEV. -$config['search_api.server.solr']['backend_config']['connector_config']['scheme'] = 'http'; +$config['search_api.server.solr']['backend_config']['connector'] = 'solr_cloud_basic_auth'; +$config['search_api.server.solr']['backend_config']['connector_config']['username'] = 'solr'; +$config['search_api.server.solr']['backend_config']['connector_config']['password'] = 'SolrRocks'; $config['search_api.server.solr']['backend_config']['connector_config']['host'] = 'solr'; +$config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'collection_1'; $config['search_api.server.solr']['backend_config']['connector_config']['port'] = '8983'; $config['search_api.server.solr']['backend_config']['connector_config']['path'] = '/'; -$config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'dev'; +$config['search_api.server.solr']['backend_config']['connector_config']['scheme'] = 'http'; // Override SMTP configuration for DDEV. $config['smtp.settings']['smtp_host'] = 'localhost'; From 39baff0616193f1c504553f6403a98dd29c998bf Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Thu, 11 Jun 2026 11:41:11 +0100 Subject: [PATCH 04/17] Update Solr manifest and repository checks --- commands/host/_lib/check-ddev-solr.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/commands/host/_lib/check-ddev-solr.sh b/commands/host/_lib/check-ddev-solr.sh index 80f3fdc..64f4d02 100644 --- a/commands/host/_lib/check-ddev-solr.sh +++ b/commands/host/_lib/check-ddev-solr.sh @@ -1,24 +1,25 @@ #ddev-generated #annertech-ddev -SOLR_MANIFEST="$APPROOT/.ddev/addon-metadata/solr/manifest.yaml" +SOLR_MANIFEST="$APPROOT/.ddev/addon-metadata/ddev-solr/manifest.yaml" if [[ ! -f "$SOLR_MANIFEST" ]]; then - pass "ddev-drupal-solr not installed — project does not use Solr" + pass "ddev-solr not installed — project does not use Solr" else SOLR_VERSION=$(grep -E '^version:' "$SOLR_MANIFEST" | awk -F': ' '{print $2}' | tr -d '"' | xargs) SOLR_REPO=$(grep -E '^repository:' "$SOLR_MANIFEST" | awk -F': ' '{print $2}' | tr -d '"' | xargs) - if [[ "$SOLR_REPO" == "ddev/ddev-drupal-solr" || "$SOLR_REPO" == "ddev/ddev-drupal9-solr" ]]; then - pass "ddev-drupal-solr repository is correct ($SOLR_REPO)" + if [[ "$SOLR_REPO" == "ddev/ddev-solr" ]]; then + pass "ddev-solr repository is correct ($SOLR_REPO)" else - fail "ddev-drupal-solr repository is '$SOLR_REPO' — expected 'ddev/ddev-drupal-solr' or 'ddev/ddev-drupal9-solr'" - warn "Install the correct addon with: 'ddev add-on get ddev/ddev-drupal-solr --version $DDEV_SOLR_VERSION'" + fail "ddev-solr repository is '$SOLR_REPO' — expected 'ddev/ddev-solr'" + warn "Install the correct addon with: 'ddev add-on get ddev/ddev-solr --version $DDEV_SOLR_VERSION'" fi if [[ "$SOLR_VERSION" == "$DDEV_SOLR_VERSION" ]]; then - pass "ddev-drupal-solr version is $DDEV_SOLR_VERSION" + pass "ddev-solr version is $DDEV_SOLR_VERSION" else - fail "ddev-drupal-solr version '$SOLR_VERSION' is not supported — only $DDEV_SOLR_VERSION is compatible" - warn "Install the correct version with: 'ddev add-on get ddev/ddev-drupal-solr --version $DDEV_SOLR_VERSION'" + fail "ddev-solr version '$SOLR_VERSION' is not supported — only $DDEV_SOLR_VERSION is compatible" + warn "Install the correct version with: 'ddev add-on get ddev/ddev-solr --version $DDEV_SOLR_VERSION'" fi fi + From c3f1b6f75d5012cb8e26de4f4e54bc29e4973dcc Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Thu, 11 Jun 2026 13:18:01 +0100 Subject: [PATCH 05/17] Update the precommit check for ddev solr --- scripts/git-hooks/pre-commit | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit index f57927b..0246d9b 100755 --- a/scripts/git-hooks/pre-commit +++ b/scripts/git-hooks/pre-commit @@ -123,27 +123,31 @@ if [ -n "$STAGED_FILES" ]; then fi # -# Abort commit if you are using an incompatible or unexpected ddev-drupal-solr addon +# Abort commit if you are using an incompatible Solr version # -SOLR_MANIFEST_FILE=".ddev/addon-metadata/solr/manifest.yaml" +SOLR_MANIFEST_FILE=".ddev/addon-metadata/ddev-solr/manifest.yaml" STAGED_FILES=$(git diff --cached --name-only | grep -F "$SOLR_MANIFEST_FILE") if [ -n "$STAGED_FILES" ]; then - SOLR_VERSION=$(grep -E '^version:' "$SOLR_MANIFEST_FILE" | awk -F': ' '{print $2}' | tr -d '"' | xargs) - SOLR_REPO=$(grep -E '^repository:' "$SOLR_MANIFEST_FILE" | awk -F': ' '{print $2}' | tr -d '"' | xargs) + SOLR_VERSION_OUTPUT=$(ddev solr --version 2>/dev/null) - if [[ "$SOLR_REPO" != "ddev/ddev-drupal-solr" ]]; then - echo "COMMIT REJECTED: Unexpected Solr addon repository: '$SOLR_REPO'" - echo "Expected: 'ddev/ddev-drupal-solr'" - echo "Install the correct addon with: 'ddev add-on get ddev/ddev-drupal-solr --version v1.2.3'" + if [[ -z "$SOLR_VERSION_OUTPUT" ]]; then + echo "COMMIT REJECTED: Could not determine Solr version. Is ddev running?" + echo "Run 'ddev start' and try again." exit 1 fi - if [[ "$SOLR_VERSION" != "v1.2.3" ]]; then - echo "COMMIT REJECTED: ddev-drupal-solr version '$SOLR_VERSION' is not supported." - echo "Only v1.2.3 is compatible. Install it with: 'ddev add-on get ddev/ddev-drupal-solr --version v1.2.3'" + SOLR_VERSION=$(echo "$SOLR_VERSION_OUTPUT" | awk '{print $NF}') + MAJOR_VERSION=$(echo "$SOLR_VERSION" | cut -d'.' -f1) + + if [[ "$MAJOR_VERSION" != "9" ]]; then + echo "COMMIT REJECTED: Solr version '$SOLR_VERSION' is not supported." + echo "Only Solr 9.x is compatible." + echo "Reinstall with: 'ddev add-on get ddev/ddev-solr'" exit 1 fi + + echo "✓ Solr version $SOLR_VERSION is compatible." fi # From 22a91eb6f70850fda2397e0d86aec6171c891bb0 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Thu, 11 Jun 2026 13:41:50 +0100 Subject: [PATCH 06/17] handle solr version other than 8 to 9 --- commands/host/install-solr | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/commands/host/install-solr b/commands/host/install-solr index 0f7d6a0..c365ff4 100644 --- a/commands/host/install-solr +++ b/commands/host/install-solr @@ -54,17 +54,25 @@ configure_upsun() { fi echo_yellow "↳ Removing old solr conf for upsun..." - if [ -d .platform/solr-conf/8.x ]; then - git rm -rf .platform/solr-conf/8.x - git commit -m "remove the old solr configuration" + OLD_SOLR_CONF=$(find .platform/solr-conf -mindepth 1 -maxdepth 1 -type d ! -name "9.x" 2>/dev/null | head -1) + + if [ -n "$OLD_SOLR_CONF" ]; then + echo_yellow "↳ Found old solr conf: $OLD_SOLR_CONF, removing..." + git rm -rf "$OLD_SOLR_CONF" + git commit -m "remove the old solr configuration ($OLD_SOLR_CONF)" else - echo_yellow "↳ .platform/solr-conf/8.x not found, skipping removal." + echo_yellow "↳ No old solr conf directory found, skipping removal." fi echo_yellow "↳ Copying new solr 9 configuration..." + if [ -d ".platform/solr-conf/9.x" ]; then + echo_yellow "↳ .platform/solr-conf/9.x already exists, overwriting..." + rm -rf .platform/solr-conf/9.x + fi + cp -r "$SOLR_CONF_SOURCE" .platform/solr-conf git add .platform/solr-conf - git commit -m "add new solr 9 configuration" + git commit -m "add new solr 9 configuration" || echo_yellow "↳ Nothing to commit for solr 9 configuration." echo_green "✓ Old solr configuration replaced with solr 9 configuration." # Update services.yaml @@ -76,11 +84,12 @@ configure_upsun() { echo_yellow "Updating $SERVICES_FILE..." # Solr version - if grep -q "solr:9.4" "$SERVICES_FILE"; then + if grep -q "type: solr:9.4" "$SERVICES_FILE"; then echo_yellow "↳ Solr version already updated, skipping." else - sed -i 's/type: solr:8\.0/type: solr:9.4/g' "$SERVICES_FILE" - echo_green "✓ solr 8.0 -> 9.4" + CURRENT_VERSION=$(grep -E 'type: solr:' "$SERVICES_FILE" | awk -F'solr:' '{print $2}' | xargs) + sed -i 's/type: solr:[0-9]\+\.[0-9]\+/type: solr:9.4/g' "$SERVICES_FILE" + echo_green "✓ solr:${CURRENT_VERSION} -> 9.4" fi # Solr core name @@ -101,7 +110,7 @@ configure_upsun() { echo "" echo_yellow "Review changes with: 'git diff $SERVICES_FILE'" - echo_yellow "If changes look good, commit with: 'git commit $SERVICES_FILE -m \"update solr 8 to 9 configuration\"'" + echo_yellow "If changes look good, commit with: 'git commit $SERVICES_FILE -m \"update solr to 9 configuration\"'" } remove_old_config @@ -110,6 +119,7 @@ configure_upsun echo "" echo_green "✓ ddev-solr installed successfully." -echo_yellow "↳ Run 'ddev restart' to apply changes." +echo_yellow "↳ Running 'ddev restart' to apply changes." echo_yellow "↳ After restart, run 'ddev solr9 -c' to configure Solr and rebuild the index." +ddev restart echo_green "✓ Done. Solr will be available at: ${DDEV_PRIMARY_URL}:8983" From abe3c3f6b1db3bc49d46d0b3dd3c54f10c3ea987 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:30:22 +0100 Subject: [PATCH 07/17] rename solr9 commands --- commands/host/{solr9 => solr9-local} | 6 +++--- commands/host/{install-solr => solr9-migrate} | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename commands/host/{solr9 => solr9-local} (96%) rename commands/host/{install-solr => solr9-migrate} (98%) diff --git a/commands/host/solr9 b/commands/host/solr9-local similarity index 96% rename from commands/host/solr9 rename to commands/host/solr9-local index 7cca079..5431ff4 100644 --- a/commands/host/solr9 +++ b/commands/host/solr9-local @@ -2,9 +2,9 @@ #annertech-ddev ## Description: Install ddev/ddev-solr addon -## Usage: solr9 [-c] -## Example: "ddev solr9" -## Example: "ddev solr9 -c" +## Usage: solr9-local [-c] +## Example: "ddev solr9-local" +## Example: "ddev solr9-local -c" ## Flags: [{"Name":"c","Usage":"Run Solr setup and configuration"}] RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' diff --git a/commands/host/install-solr b/commands/host/solr9-migrate similarity index 98% rename from commands/host/install-solr rename to commands/host/solr9-migrate index c365ff4..09a8789 100644 --- a/commands/host/install-solr +++ b/commands/host/solr9-migrate @@ -2,8 +2,8 @@ #annertech-ddev ## Description: Install ddev/ddev-solr addon -## Usage: install-solr -## Example: "ddev install-solr" +## Usage: solr9-migrate +## Example: "ddev solr9-migrate" set -e From 496e145c9e96a5735c7ae96120714fe323388ea8 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Thu, 2 Jul 2026 13:05:05 +0100 Subject: [PATCH 08/17] update command descriptions --- commands/host/solr9-local | 2 +- commands/host/solr9-migrate | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/host/solr9-local b/commands/host/solr9-local index 5431ff4..a973039 100644 --- a/commands/host/solr9-local +++ b/commands/host/solr9-local @@ -1,7 +1,7 @@ #!/usr/bin/env bash #annertech-ddev -## Description: Install ddev/ddev-solr addon +## Description: setup ddev-solr for local use, creates a collection & rebuilds index ## Usage: solr9-local [-c] ## Example: "ddev solr9-local" ## Example: "ddev solr9-local -c" diff --git a/commands/host/solr9-migrate b/commands/host/solr9-migrate index 09a8789..3252388 100644 --- a/commands/host/solr9-migrate +++ b/commands/host/solr9-migrate @@ -1,7 +1,7 @@ #!/usr/bin/env bash #annertech-ddev -## Description: Install ddev/ddev-solr addon +## Description: Installs ddev/ddev-solr addon and will attempt to update solr for upsun configuration ## Usage: solr9-migrate ## Example: "ddev solr9-migrate" From 88bde7abfc41234bdc3d4d1175c4874f9297fa6f Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Mon, 6 Jul 2026 16:37:32 +0100 Subject: [PATCH 09/17] address issue where dir is missing --- commands/host/solr9-migrate | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/host/solr9-migrate b/commands/host/solr9-migrate index 3252388..38e7ede 100644 --- a/commands/host/solr9-migrate +++ b/commands/host/solr9-migrate @@ -26,10 +26,10 @@ remove_old_config() { echo_yellow "↳ .ddev/docker-compose.solr.yaml not found, skipping." fi - if [ -d .ddev/solr ]; then - git rm -rf .ddev/solr/ + if git ls-files .ddev/solr | grep -q .; then + git rm -rf .ddev/solr else - echo_yellow "↳ .ddev/solr/ not found, skipping." + echo_yellow "↳ No tracked files in .ddev/solr, skipping." fi git commit -m "remove the ddev drupal solr" || echo_yellow "↳ Nothing to commit for old config removal." From 493773e85a4abb0fe040515f9fa218a5f2ce0c99 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Wed, 15 Jul 2026 10:49:05 +0100 Subject: [PATCH 10/17] remove the ddev-drupal-solr --- commands/host/solr9-migrate | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/commands/host/solr9-migrate b/commands/host/solr9-migrate index 38e7ede..297b7d9 100644 --- a/commands/host/solr9-migrate +++ b/commands/host/solr9-migrate @@ -18,21 +18,8 @@ SOLR_CONF_SOURCE="web/modules/contrib/search_api_solr/solr-conf-templates/9.x" echo_yellow "Installing ddev/ddev-solr addon..." remove_old_config() { - echo_yellow "Removing old ddev solr configuration..." - - if [ -f .ddev/docker-compose.solr.yaml ]; then - git rm .ddev/docker-compose.solr.yaml - else - echo_yellow "↳ .ddev/docker-compose.solr.yaml not found, skipping." - fi - - if git ls-files .ddev/solr | grep -q .; then - git rm -rf .ddev/solr - else - echo_yellow "↳ No tracked files in .ddev/solr, skipping." - fi - - git commit -m "remove the ddev drupal solr" || echo_yellow "↳ Nothing to commit for old config removal." + echo_yellow "Removing old ddev/ddev-drupal-solr addon..." + ddev add-on remove ddev/ddev-drupal-solr || echo_yellow "↳ ddev/ddev-drupal-solr not installed, skipping." echo_green "✓ Old ddev solr configuration removed." } From 4bf5e9adf5e2cdb6a2dea474ea63198f675d0bd4 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Wed, 15 Jul 2026 10:51:56 +0100 Subject: [PATCH 11/17] validate that ddev primary url is set --- commands/host/solr9-migrate | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/commands/host/solr9-migrate b/commands/host/solr9-migrate index 297b7d9..066312f 100644 --- a/commands/host/solr9-migrate +++ b/commands/host/solr9-migrate @@ -109,4 +109,9 @@ echo_green "✓ ddev-solr installed successfully." echo_yellow "↳ Running 'ddev restart' to apply changes." echo_yellow "↳ After restart, run 'ddev solr9 -c' to configure Solr and rebuild the index." ddev restart -echo_green "✓ Done. Solr will be available at: ${DDEV_PRIMARY_URL}:8983" + +if [ -z "$DDEV_PRIMARY_URL" ]; then + echo_green "✓ Done." +else + echo_green "✓ Done. Solr will be available at: ${DDEV_PRIMARY_URL}:8983" +fi From 05850ff9ea44013816cf06c5ebfeaf046533934e Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Wed, 15 Jul 2026 10:52:27 +0100 Subject: [PATCH 12/17] handle multiple old versions of solr conf --- commands/host/solr9-migrate | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/commands/host/solr9-migrate b/commands/host/solr9-migrate index 066312f..9fc3492 100644 --- a/commands/host/solr9-migrate +++ b/commands/host/solr9-migrate @@ -41,12 +41,14 @@ configure_upsun() { fi echo_yellow "↳ Removing old solr conf for upsun..." - OLD_SOLR_CONF=$(find .platform/solr-conf -mindepth 1 -maxdepth 1 -type d ! -name "9.x" 2>/dev/null | head -1) - - if [ -n "$OLD_SOLR_CONF" ]; then - echo_yellow "↳ Found old solr conf: $OLD_SOLR_CONF, removing..." - git rm -rf "$OLD_SOLR_CONF" - git commit -m "remove the old solr configuration ($OLD_SOLR_CONF)" + OLD_SOLR_CONFS=$(find .platform/solr-conf -mindepth 1 -maxdepth 1 -type d ! -name "9.x" 2>/dev/null) + + if [ -n "$OLD_SOLR_CONFS" ]; then + while IFS= read -r old_conf; do + echo_yellow "↳ Removing: $old_conf" + git rm -rf "$old_conf" + done <<< "$OLD_SOLR_CONFS" + git commit -m "remove old solr configurations" else echo_yellow "↳ No old solr conf directory found, skipping removal." fi From c7b22d193434cf04e4316ccc6cf6d6c101300977 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Wed, 15 Jul 2026 10:55:38 +0100 Subject: [PATCH 13/17] handle missing services file --- commands/host/solr9-migrate | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/commands/host/solr9-migrate b/commands/host/solr9-migrate index 9fc3492..821e72d 100644 --- a/commands/host/solr9-migrate +++ b/commands/host/solr9-migrate @@ -15,7 +15,17 @@ echo_yellow() { echo -e "${YELLOW}$1${NC}"; } SERVICES_FILE=".platform/services.yaml" SOLR_CONF_SOURCE="web/modules/contrib/search_api_solr/solr-conf-templates/9.x" -echo_yellow "Installing ddev/ddev-solr addon..." +if [ ! -f "$SERVICES_FILE" ]; then + echo_red "✗ File not found: $SERVICES_FILE" + exit 1 +fi + +if [ ! -d "$SOLR_CONF_SOURCE" ]; then + echo_red "✗ Solr config templates not found at $SOLR_CONF_SOURCE. Is search_api_solr installed?" + exit 1 +fi + +echo_yellow "Starting Solr migration..." remove_old_config() { echo_yellow "Removing old ddev/ddev-drupal-solr addon..." @@ -34,12 +44,6 @@ install_new_addon() { configure_upsun() { echo_yellow "Configuring upsun solr..." - # Replace solr conf directory - if [ ! -d "$SOLR_CONF_SOURCE" ]; then - echo_red "✗ Solr config templates not found at $SOLR_CONF_SOURCE. Is search_api_solr installed?" - exit 1 - fi - echo_yellow "↳ Removing old solr conf for upsun..." OLD_SOLR_CONFS=$(find .platform/solr-conf -mindepth 1 -maxdepth 1 -type d ! -name "9.x" 2>/dev/null) @@ -65,11 +69,6 @@ configure_upsun() { echo_green "✓ Old solr configuration replaced with solr 9 configuration." # Update services.yaml - if [ ! -f "$SERVICES_FILE" ]; then - echo_red "✗ File not found: $SERVICES_FILE" - exit 1 - fi - echo_yellow "Updating $SERVICES_FILE..." # Solr version From a142f7a083d85bde9291a2b3a5e0f13491fad16a Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Wed, 15 Jul 2026 11:25:01 +0100 Subject: [PATCH 14/17] handle custom installed solr --- commands/host/solr9-migrate | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/commands/host/solr9-migrate b/commands/host/solr9-migrate index 821e72d..d2d57fe 100644 --- a/commands/host/solr9-migrate +++ b/commands/host/solr9-migrate @@ -28,9 +28,34 @@ fi echo_yellow "Starting Solr migration..." remove_old_config() { - echo_yellow "Removing old ddev/ddev-drupal-solr addon..." - ddev add-on remove ddev/ddev-drupal-solr || echo_yellow "↳ ddev/ddev-drupal-solr not installed, skipping." - echo_green "✓ Old ddev solr configuration removed." + if ddev add-on list --installed | grep -q "ddev-drupal-solr"; then + echo_yellow "Removing old ddev/ddev-drupal-solr addon..." + ddev add-on remove ddev/ddev-drupal-solr + echo_green "✓ Old ddev solr configuration removed." + else + echo_yellow "ddev/ddev-drupal-solr addon not installed, checking for manual files..." + + FILES_REMOVED=0 + + if [ -f .ddev/docker-compose.solr.yaml ]; then + echo_yellow "↳ Found .ddev/docker-compose.solr.yaml, removing..." + git rm .ddev/docker-compose.solr.yaml + FILES_REMOVED=1 + fi + + if git ls-files .ddev/solr | grep -q .; then + echo_yellow "↳ Found tracked files in .ddev/solr, removing..." + git rm -rf .ddev/solr + FILES_REMOVED=1 + fi + + if [ $FILES_REMOVED -eq 1 ]; then + git commit -m "remove manually installed solr configuration" || echo_yellow "↳ Nothing to commit." + echo_green "✓ Old solr configuration removed." + else + echo_yellow "↳ No old solr files found, skipping." + fi + fi } install_new_addon() { From f22789937772324310404eba380a2ac06194b8b6 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Wed, 15 Jul 2026 13:53:06 +0100 Subject: [PATCH 15/17] add a snippet to set an ENV variable for use in settings.php --- commands/host/solr9-migrate | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/commands/host/solr9-migrate b/commands/host/solr9-migrate index d2d57fe..5824625 100644 --- a/commands/host/solr9-migrate +++ b/commands/host/solr9-migrate @@ -66,6 +66,23 @@ install_new_addon() { echo_green "✓ ddev/ddev-solr installed." } +update_env_anner() { + echo_yellow "Updating .ddev/.env..." + + if [ ! -f .ddev/.env ]; then + touch .ddev/.env + fi + + if grep -q "^DDEV_SOLR=" .ddev/.env; then + sed -i '/^DDEV_SOLR=/d' .ddev/.env + fi + + echo 'DDEV_SOLR="ddev-solr"' >> .ddev/.env + git add .ddev/.env + git commit -m "add DDEV_SOLR to .ddev/.env" || echo_yellow "↳ Nothing to commit for .ddev/.env" + echo_green "✓ .ddev/.env updated with DDEV_SOLR=ddev-solr" +} + configure_upsun() { echo_yellow "Configuring upsun solr..." @@ -129,6 +146,7 @@ configure_upsun() { remove_old_config install_new_addon configure_upsun +update_env_anner echo "" echo_green "✓ ddev-solr installed successfully." From 6bf6929f738b3c187815a34eb75f52c259700762 Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Wed, 15 Jul 2026 13:54:20 +0100 Subject: [PATCH 16/17] update cli command description --- commands/host/solr9-local | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/host/solr9-local b/commands/host/solr9-local index a973039..6671b22 100644 --- a/commands/host/solr9-local +++ b/commands/host/solr9-local @@ -5,7 +5,7 @@ ## Usage: solr9-local [-c] ## Example: "ddev solr9-local" ## Example: "ddev solr9-local -c" -## Flags: [{"Name":"c","Usage":"Run Solr setup and configuration"}] +## Flags: [{"Name":"c","Shorthand":"c","Usage":"Run Solr setup and configuration"}] RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' echo_red() { echo -e "${RED}$1${NC}" >&2; } From cd4da47b81a380f8536caaa1dfe7d320899fdc3b Mon Sep 17 00:00:00 2001 From: Gavin Hughes <1315627+gavin-webstuff@users.noreply.github.com> Date: Wed, 15 Jul 2026 14:01:02 +0100 Subject: [PATCH 17/17] update settings file to explicit pick up ddev-solr config --- settings.local.devmode.php | 15 ++++++++++----- settings.local.perfmode.php | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/settings.local.devmode.php b/settings.local.devmode.php index 8701f02..2c295a0 100644 --- a/settings.local.devmode.php +++ b/settings.local.devmode.php @@ -20,14 +20,19 @@ $config['stage_file_proxy.settings']['origin'] = getenv('STAGE_FILE_PROXY_URL'); // Override SOLR configuration for DDEV. -$config['search_api.server.solr']['backend_config']['connector'] = 'solr_cloud_basic_auth'; -$config['search_api.server.solr']['backend_config']['connector_config']['username'] = 'solr'; -$config['search_api.server.solr']['backend_config']['connector_config']['password'] = 'SolrRocks'; +$config['search_api.server.solr']['backend_config']['connector_config']['scheme'] = 'http'; $config['search_api.server.solr']['backend_config']['connector_config']['host'] = 'solr'; -$config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'collection_1'; $config['search_api.server.solr']['backend_config']['connector_config']['port'] = '8983'; $config['search_api.server.solr']['backend_config']['connector_config']['path'] = '/'; -$config['search_api.server.solr']['backend_config']['connector_config']['scheme'] = 'http'; +$config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'dev'; + +// These changes are for ddev-solr only. +if (getenv('DDEV_SOLR') === 'ddev-solr') { + $config['search_api.server.solr']['backend_config']['connector'] = 'solr_cloud_basic_auth'; + $config['search_api.server.solr']['backend_config']['connector_config']['username'] = 'solr'; + $config['search_api.server.solr']['backend_config']['connector_config']['password'] = 'SolrRocks'; + $config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'collection_1'; +} // Override SMTP configuration for DDEV. $config['smtp.settings']['smtp_host'] = 'localhost'; diff --git a/settings.local.perfmode.php b/settings.local.perfmode.php index 11c1504..5c00b24 100644 --- a/settings.local.perfmode.php +++ b/settings.local.perfmode.php @@ -20,14 +20,19 @@ $config['stage_file_proxy.settings']['origin'] = getenv('STAGE_FILE_PROXY_URL'); // Override SOLR configuration for DDEV. -$config['search_api.server.solr']['backend_config']['connector'] = 'solr_cloud_basic_auth'; -$config['search_api.server.solr']['backend_config']['connector_config']['username'] = 'solr'; -$config['search_api.server.solr']['backend_config']['connector_config']['password'] = 'SolrRocks'; +$config['search_api.server.solr']['backend_config']['connector_config']['scheme'] = 'http'; $config['search_api.server.solr']['backend_config']['connector_config']['host'] = 'solr'; -$config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'collection_1'; $config['search_api.server.solr']['backend_config']['connector_config']['port'] = '8983'; $config['search_api.server.solr']['backend_config']['connector_config']['path'] = '/'; -$config['search_api.server.solr']['backend_config']['connector_config']['scheme'] = 'http'; +$config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'dev'; + +// These changes are for ddev-solr only. +if (getenv('DDEV_SOLR') === 'ddev-solr') { + $config['search_api.server.solr']['backend_config']['connector'] = 'solr_cloud_basic_auth'; + $config['search_api.server.solr']['backend_config']['connector_config']['username'] = 'solr'; + $config['search_api.server.solr']['backend_config']['connector_config']['password'] = 'SolrRocks'; + $config['search_api.server.solr']['backend_config']['connector_config']['core'] = 'collection_1'; +} // Override SMTP configuration for DDEV. $config['smtp.settings']['smtp_host'] = 'localhost';