From 601aef5b994a6c876ef1910df7732ddcafe8cc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Br=C3=A4ndle?= Date: Fri, 12 Jul 2024 18:15:21 +0200 Subject: [PATCH] Adaptations for 3.4.0; fixes for short locale (#11) --- LucenePlugin.php | 14 ++++++--- classes/SolrWebService.php | 12 ++++++-- embedded/solr81/ojs/conf/schema.xml | 45 +++++++++++++++-------------- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/LucenePlugin.php b/LucenePlugin.php index a03c27e..70c9ff4 100644 --- a/LucenePlugin.php +++ b/LucenePlugin.php @@ -57,6 +57,12 @@ class LucenePlugin extends GenericPlugin { /** @var array */ var $_facets; + public function __construct() + { + parent::__construct(); + $this->application = Application::get()->getName(); + } + // // Getters and Setters @@ -541,7 +547,7 @@ function callbackArticleMetadataChanged($hookName, $params) { $this->_solrWebService->setArticleStatus($article->getId()); // in OJS core in many cases callbackArticleChangesFinished is not called. // So we call it ourselves, it won't do anything is pull-indexing is active - $this->callbackArticleChangesFinished(null, null); + $this->callbackArticleChangesFinished(null, null, $article->getData('contextId')); return true; } @@ -567,7 +573,7 @@ function callbackSubmissionFileChanged($hookName, $params) { $this->_solrWebService->setArticleStatus($article->getId()); // in OJS core in many cases callbackArticleChangesFinished is not called. // So we call it ourselves, it won't do anything is pull-indexing is active - $this->callbackArticleChangesFinished(null, null); + $this->callbackArticleChangesFinished(null, null,$article->getData('contextId')); return true; } @@ -608,7 +614,7 @@ function callbackUnpublish($hookName, $params) { /** * @see ArticleSearchIndex::articleChangesFinished() */ - function callbackArticleChangesFinished($hookName, $params) { + function callbackArticleChangesFinished($hookName, $params, $journalId = null) { // In the case of pull-indexing we ignore this call // and let the Solr server initiate indexing. if ($this->getSetting(CONTEXT_SITE, 'pullIndexing')) return true; @@ -620,7 +626,7 @@ function callbackArticleChangesFinished($hookName, $params) { // locked in case a race condition with a large index update // occurs. $solrWebService = $this->getSolrWebService(); - $result = $solrWebService->pushChangedArticles(5); + $result = $solrWebService->pushChangedArticles(5, $journalId); if (is_null($result)) { $this->_informTechAdmin($solrWebService->getServiceMessage()); } diff --git a/classes/SolrWebService.php b/classes/SolrWebService.php index caff0aa..14e7bf6 100644 --- a/classes/SolrWebService.php +++ b/classes/SolrWebService.php @@ -774,6 +774,7 @@ function _makeRequest($url, $params = [], $method = 'GET') : ?\DOMXpath { } else { throw new \Exception('Unknown request method!'); } + // $guzzleParams['debug'] = true; $response = $client->request($method, $url, $guzzleParams); // Did we get a response at all? @@ -1165,8 +1166,12 @@ function _getSearchQueryParameters($searchRequest, $solr7 = false) { // Add the authors as an filter query (if set). $authors = $searchRequest->getAuthors(); if (!empty($authors)) { - foreach ($authors as $author) { - $filterFieldsSerialized[] = 'authors_txt:' . $author; + if (is_array($authors)) { + foreach ($authors as $author) { + $filterFieldsSerialized[] = 'authors_txt:' . $author; + } + } else { + $filterFieldsSerialized[] = 'authors_txt:' . $authors; } } // Add the journal as a filter query (if set). @@ -1962,7 +1967,8 @@ function _cacheMiss($cache, $id) { // Localized and multiformat fields have a locale suffix. $locale = $fieldSuffix; - if ($locale != 'txt') { + // check for double locales + if ($locale != 'txt' && ctype_upper($locale)) { $locale = array_pop($fieldNameParts) . '_' . $locale; } diff --git a/embedded/solr81/ojs/conf/schema.xml b/embedded/solr81/ojs/conf/schema.xml index 83091fe..72a6796 100644 --- a/embedded/solr81/ojs/conf/schema.xml +++ b/embedded/solr81/ojs/conf/schema.xml @@ -453,32 +453,33 @@ support an additional locale, you can add a dynamic field definition here. The locale names correspond 1:1 to OJS locale names. The type attribute points to one of the field type definitions above. --> - - - - - - - - - + + + + + + + + + - - - + + + + - - - + + + - - - - - - - + + + + + + +