From 94fba7fd5f97e4197ba0f57a1417b0553bd4f910 Mon Sep 17 00:00:00 2001 From: Diego Pino Navarro Date: Mon, 22 Jul 2024 15:24:55 -0400 Subject: [PATCH 1/3] Add scheme to config. Also add some more info so we can debug --- src/Plugin/ImporterAdapter/SolrImporter.php | 28 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Plugin/ImporterAdapter/SolrImporter.php b/src/Plugin/ImporterAdapter/SolrImporter.php index d062994..6219b34 100644 --- a/src/Plugin/ImporterAdapter/SolrImporter.php +++ b/src/Plugin/ImporterAdapter/SolrImporter.php @@ -155,6 +155,18 @@ public function interactiveForm(array $parents, FormStateInterface $form_state): '#default_value' => $form_state->getValue(array_merge($parents, ['solarium_config', 'islandora_collection'])), ], + 'scheme' => [ + '#type' => 'radios', + '#required' => TRUE, + '#title' => $this->t('The Scheme (protocol) of your Solr Server'), + '#options' => [ + 'http' => 'HTTP', + 'https' => 'HTTPS' + ], + '#description' => $this->t('If you port is 443 most likely your scheme is going to be HTTPS.'), + '#default_value' => $form_state->getValue(array_merge($parents, + ['solarium_config', 'schema'])), + ], 'host' => [ '#type' => 'textfield', '#required' => TRUE, @@ -344,8 +356,8 @@ public function interactiveForm(array $parents, FormStateInterface $form_state): '#required' => FALSE, '#description_display' => 'before', '#description' => $this->t('Additional Datastreams to fetch. OBJ datastream will always be fetched. Not all datastreams listed here might be present once your data is fetched.'), - '#default_value' => $datastreams_values_combined, - '#options' => $datastreams_source, + '#default_value' => $datastreams_values_combined ?? [], + '#options' => $datastreams_source ?? [], ], 'datastreams_how' => [ '#access' => !empty($cmodels), @@ -437,6 +449,7 @@ public static function validateSolrConfig($element, FormStateInterface $form_sta 'endpoint' => [ 'amiremote' => [ 'host' => $config['host'], + 'scheme' => $config['scheme'] ?? 'http', 'port' => $config['port'], 'path' => $config['path'], ], @@ -470,7 +483,9 @@ public static function validateSolrConfig($element, FormStateInterface $form_sta $result = $client->ping($ping); } catch (\Exception $e) { $form_state->setError($element, - t('Ups. We could not contact your server. Check if your settings are correct and/or firewalls are open for this IP address.')); + t('Ups. We could not contact your server. Check if your settings are correct and/or firewalls are open for this IP address. Remote error is @e', [ + '@e' => $e->getMessage() + ])); } } @@ -495,6 +510,7 @@ public function getInfo(array $config, FormStateInterface $form_state, $page = 0 'endpoint' => [ 'amiremote' => [ 'host' => $config['solarium_config']['host'], + 'scheme' => $config['solarium_config']['scheme'], 'port' => $config['solarium_config']['port'], 'path' => $config['solarium_config']['path'], ], @@ -523,7 +539,10 @@ public function getInfo(array $config, FormStateInterface $form_state, $page = 0 $ping_sucessful = $result->getData(); } catch (\Exception $e) { $form_state->setError($element, - $this->t('Ups. We could not contact your server. Check if your settings,ports,core,etc are correct and/or firewalls are open for this IP address.')); + $this->t('Ups. We could not contact your server. Check if your settings,ports,core,etc are correct and/or firewalls are open for this IP address. The error thrown is: @e', + [ + '@e' => $e->getMessage() + ])); $form_state->setValue(['pluginconfig','ready'], FALSE); return $tabdata; } @@ -781,6 +800,7 @@ public function getData(array $config, $page = 0, $per_page = 20): array { 'endpoint' => [ 'amiremote' => [ 'host' => $config['solarium_config']['host'], + 'scheme' => $config['solarium_config']['scheme'] ?? 'http', 'port' => $config['solarium_config']['port'], 'path' => $config['solarium_config']['path'], ], From d806eb6cdf261c7f1ab4766f271b543de4ab1bfb Mon Sep 17 00:00:00 2001 From: Diego Pino Navarro Date: Mon, 22 Jul 2024 15:24:55 -0400 Subject: [PATCH 2/3] Add scheme to config. Also add some more info so we can debug --- src/Plugin/ImporterAdapter/SolrImporter.php | 28 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Plugin/ImporterAdapter/SolrImporter.php b/src/Plugin/ImporterAdapter/SolrImporter.php index 1ae254f..745e3c8 100644 --- a/src/Plugin/ImporterAdapter/SolrImporter.php +++ b/src/Plugin/ImporterAdapter/SolrImporter.php @@ -155,6 +155,18 @@ public function interactiveForm(array $parents, FormStateInterface $form_state): '#default_value' => $form_state->getValue(array_merge($parents, ['solarium_config', 'islandora_collection'])), ], + 'scheme' => [ + '#type' => 'radios', + '#required' => TRUE, + '#title' => $this->t('The Scheme (protocol) of your Solr Server'), + '#options' => [ + 'http' => 'HTTP', + 'https' => 'HTTPS' + ], + '#description' => $this->t('If you port is 443 most likely your scheme is going to be HTTPS.'), + '#default_value' => $form_state->getValue(array_merge($parents, + ['solarium_config', 'schema'])), + ], 'host' => [ '#type' => 'textfield', '#required' => TRUE, @@ -344,8 +356,8 @@ public function interactiveForm(array $parents, FormStateInterface $form_state): '#required' => FALSE, '#description_display' => 'before', '#description' => $this->t('Additional Datastreams to fetch. OBJ datastream will always be fetched. Not all datastreams listed here might be present once your data is fetched.'), - '#default_value' => $datastreams_values_combined, - '#options' => $datastreams_source, + '#default_value' => $datastreams_values_combined ?? [], + '#options' => $datastreams_source ?? [], ], 'datastreams_how' => [ '#access' => !empty($cmodels), @@ -437,6 +449,7 @@ public static function validateSolrConfig($element, FormStateInterface $form_sta 'endpoint' => [ 'amiremote' => [ 'host' => $config['host'], + 'scheme' => $config['scheme'] ?? 'http', 'port' => $config['port'], 'path' => $config['path'], ], @@ -470,7 +483,9 @@ public static function validateSolrConfig($element, FormStateInterface $form_sta $result = $client->ping($ping); } catch (\Exception $e) { $form_state->setError($element, - t('Ups. We could not contact your server. Check if your settings are correct and/or firewalls are open for this IP address.')); + t('Ups. We could not contact your server. Check if your settings are correct and/or firewalls are open for this IP address. Remote error is @e', [ + '@e' => $e->getMessage() + ])); } } @@ -493,6 +508,7 @@ public function getInfo(array $config, FormStateInterface $form_state, $page = 0 'endpoint' => [ 'amiremote' => [ 'host' => $config['solarium_config']['host'], + 'scheme' => $config['solarium_config']['scheme'], 'port' => $config['solarium_config']['port'], 'path' => $config['solarium_config']['path'], ], @@ -521,7 +537,10 @@ public function getInfo(array $config, FormStateInterface $form_state, $page = 0 $ping_sucessful = $result->getData(); } catch (\Exception $e) { $form_state->setError($element, - $this->t('Ups. We could not contact your server. Check if your settings,ports,core,etc are correct and/or firewalls are open for this IP address.')); + $this->t('Ups. We could not contact your server. Check if your settings,ports,core,etc are correct and/or firewalls are open for this IP address. The error thrown is: @e', + [ + '@e' => $e->getMessage() + ])); $form_state->setValue(['pluginconfig','ready'], FALSE); return $tabdata; } @@ -779,6 +798,7 @@ public function getData(array $config, $page = 0, $per_page = 20): array { 'endpoint' => [ 'amiremote' => [ 'host' => $config['solarium_config']['host'], + 'scheme' => $config['solarium_config']['scheme'] ?? 'http', 'port' => $config['solarium_config']['port'], 'path' => $config['solarium_config']['path'], ], From b5bb6b856973855104a8ae961614919a71d53942 Mon Sep 17 00:00:00 2001 From: Diego Pino Navarro Date: Wed, 24 Jul 2024 09:29:06 -0400 Subject: [PATCH 3/3] Adds extra check for layout builder assuming maybe there is no route object at all --- .../AmiFacetsViewsBulkOperationsEventSubscriber.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/EventSubscriber/AmiFacetsViewsBulkOperationsEventSubscriber.php b/src/EventSubscriber/AmiFacetsViewsBulkOperationsEventSubscriber.php index 1dc47aa..54860b0 100644 --- a/src/EventSubscriber/AmiFacetsViewsBulkOperationsEventSubscriber.php +++ b/src/EventSubscriber/AmiFacetsViewsBulkOperationsEventSubscriber.php @@ -81,16 +81,22 @@ public function updateFacetCache(ViewsBulkOperationsEvent $event) { // We do not know here if facets will or not be in a f[] so we pass // all values (also good, respects filters). // The VBO URL facet processor will know/read from the URL Processor settings. - // Do not overridewrite once the batch starts or we will end with 0 filters. + // Do not override once the batch starts or we will end with 0 filters. // Arguments will be 'op' = 'do', _format = 'json', id = a number the batch id // Normally just checking if this is happening under the unbrella of the actual Views Route is enough // BUT ... we need to also take in account layout builder .. so in that case we check for 'op' !== do && id (the batch) // @TODO. No idea how to deal with the blocks and other options - // I could to the opposite> Save it anytime it is not a batch but bc Facets are basically processed all the time + // I could to the opposite: Save it anytime it is not a batch but bc Facets are basically processed all the time // anywhere that would be a lot of extra processing time. + // Add work around for users that disabled "layout builder" + $is_layout_builder = NULL; + $route_object = \Drupal::routeMatch()->getRouteObject(); + if ($route_object) { + $is_layout_builder = $route_object->getOption('_layout_builder'); + } if ((\Drupal::routeMatch()->getRouteName() == 'view'. '.' . $event->getView()->id(). '.' .$event->getView()->current_display) || ( - (\Drupal::routeMatch()->getRouteObject()->getOption('_layout_builder') || + ($is_layout_builder || $event->getView()->display_handler->getBaseId() == 'block') && (($exposed_input['op'] ?? NULL) !== "do") && !isset($exposed_input['id'])) ) { $this->tempStoreFactory->get($tempStoreName)->set(