From f90925fdb7a0db9a70a7ccf9c9d9be8fa6f37abf Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 10 Aug 2023 17:25:29 -0300 Subject: [PATCH 1/2] Avoid some potential issues with new installations. `text_files` could/would be initialized as null, despite not being nullable, but defining it as an empty mapping allow us to avoid warnings being emitted, such as: ``` Warning: Invalid argument supplied for foreach() in Drupal\search_api_solr\Controller\SolrConfigSetController->getConfigFiles() (line 348 of modules/contrib/search_api_solr/src/Controller/SolrConfigSetController.php). Drupal\search_api_solr\Controller\SolrConfigSetController->getConfigFiles() (Line: 61) [...] ``` --- ...solr.solr_field_type.islandora_hocr_und_7_0_0.yml | 12 ++++++++---- ...r.request_handler_select_islandora_hocr_7_0_0.yml | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/config/install/search_api_solr.solr_field_type.islandora_hocr_und_7_0_0.yml b/config/install/search_api_solr.solr_field_type.islandora_hocr_und_7_0_0.yml index 243fab0..7d54d40 100644 --- a/config/install/search_api_solr.solr_field_type.islandora_hocr_und_7_0_0.yml +++ b/config/install/search_api_solr.solr_field_type.islandora_hocr_und_7_0_0.yml @@ -1,11 +1,11 @@ langcode: en status: true dependencies: + config: + - search_api_solr.solr_field_type.text_und_7_0_0 module: - search_api_solr - islandora_hocr - config: - - search_api_solr.solr_field_type.text_und_7_0_0 id: islandora_hocr_und_7_0_0 label: 'Language Undefined hOCR Field' minimum_solr_version: 7.0.0 @@ -15,7 +15,6 @@ domains: {} field_type: name: islandora_hocr_und class: solr.TextField - storeOffsetsWithPositions: true analyzers: - type: index @@ -61,9 +60,9 @@ field_type: filters: - class: solr.SynonymGraphFilterFactory + ignoreCase: true synonyms: synonyms_und.txt expand: true - ignoreCase: true - class: solr.StopFilterFactory ignoreCase: true @@ -86,4 +85,9 @@ field_type: class: solr.LowerCaseFilterFactory - class: solr.RemoveDuplicatesTokenFilterFactory + storeOffsetsWithPositions: true +unstemmed_field_type: null +spellcheck_field_type: null +collated_field_type: null solr_configs: null +text_files: { } diff --git a/config/install/search_api_solr.solr_request_handler.request_handler_select_islandora_hocr_7_0_0.yml b/config/install/search_api_solr.solr_request_handler.request_handler_select_islandora_hocr_7_0_0.yml index 462e807..672c0d1 100644 --- a/config/install/search_api_solr.solr_request_handler.request_handler_select_islandora_hocr_7_0_0.yml +++ b/config/install/search_api_solr.solr_request_handler.request_handler_select_islandora_hocr_7_0_0.yml @@ -1,10 +1,10 @@ langcode: en status: true dependencies: - module: - - islandora_hocr config: - search_api_solr.solr_field_type.islandora_hocr_und_7_0_0 + module: + - islandora_hocr id: request_handler_select_islandora_hocr_7_0_0 label: Select w/ OCR Highlighting Component minimum_solr_version: 7.0.0 From dc922a1263fd643462fbdca02c3faafa9d8f24d0 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 10 Aug 2023 17:37:25 -0300 Subject: [PATCH 2/2] Add in post-update hook to update the config entity. --- islandora_hocr.post_update.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/islandora_hocr.post_update.php b/islandora_hocr.post_update.php index 87b2f35..0f438f0 100644 --- a/islandora_hocr.post_update.php +++ b/islandora_hocr.post_update.php @@ -27,3 +27,18 @@ function islandora_hocr_post_update_install_initial_entities() { } } + +/** + * Ensure `text_files` is not null. + * + * When Drupal initializes it, it would give it null, despite being not + * null. Giving it an empty map seems to do the trick. + */ +function islandora_hocr_post_update_ensure_field_type_has_empty_map() { + $config = \Drupal::configFactory()->getEditable('search_api_solr.solr_field_type.islandora_hocr_und_7_0_0'); + $value = $config->get('text_files'); + if ($value === NULL) { + $config->set('text_files', []) + ->save(TRUE); + } +}