Skip to content

Commit

Permalink
Adaptations for 3.4.0; fixes for short locale (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbraendle authored Jul 12, 2024
1 parent 7a45df8 commit 601aef5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 29 deletions.
14 changes: 10 additions & 4 deletions LucenePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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());
}
Expand Down
12 changes: 9 additions & 3 deletions classes/SolrWebService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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;
}

Expand Down
45 changes: 23 additions & 22 deletions embedded/solr81/ojs/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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. -->
<dynamicField name="*_ca_ES" type="text_ca" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_cs_CZ" type="text_cs" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_da_DK" type="text_da" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_de_DE" type="text_de" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_el_GR" type="text_el" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_en_US" type="text_en" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_es_ES" type="text_es" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_eu_ES" type="text_eu" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_fa_IR" type="text_fa" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_ca" type="text_ca" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_cs" type="text_cs" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_da" type="text_da" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_de" type="text_de" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_el" type="text_el" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_en" type="text_en" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_es" type="text_es" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_eu" type="text_eu" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_fa" type="text_fa" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_fr_CA" type="text_fr" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_gl_ES" type="text_gl" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_hr_HR" type="text" indexed="true" stored="true" multiValued="false" termVectors="true"/> <!-- not currently supported -->
<dynamicField name="*_it_IT" type="text_it" indexed="true" stored="true" multiValued="false" />
<dynamicField name="*_fr_FR" type="text_fr" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_gl" type="text_gl" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_hr" type="text" indexed="true" stored="true" multiValued="false" termVectors="true"/> <!-- not currently supported -->
<dynamicField name="*_it" type="text_it" indexed="true" stored="true" multiValued="false" />
<!--TODO: Activate<dynamicField name="*_ja_JP" type="text_cjk" indexed="true" stored="true" multiValued="false" />-->
<dynamicField name="*_ml_IN" type="text" indexed="true" stored="true" multiValued="false" termVectors="true" /> <!-- not currently supported -->
<dynamicField name="*_nl_NL" type="text_nl" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_nb_NO" type="text_no" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_ml" type="text" indexed="true" stored="true" multiValued="false" termVectors="true" /> <!-- not currently supported -->
<dynamicField name="*_nl" type="text_nl" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_nb" type="text_no" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_pt_BR" type="text_pt" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_pt_PT" type="text_pt" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_ro_RO" type="text_ro" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_ru_RU" type="text_ru" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_sr_SR" type="text" indexed="true" stored="true" multiValued="false" /> <!-- not currently supported -->
<dynamicField name="*_sv_SE" type="text_sv" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_tr_TR" type="text_tr" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_uk_UA" type="text" indexed="true" stored="true" multiValued="false" termVectors="true" /> <!-- not currently supported -->
<dynamicField name="*_vi_VN" type="text" indexed="true" stored="true" multiValued="false" termVectors="true" /> <!-- not currently supported -->
<dynamicField name="*_ro" type="text_ro" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_ru" type="text_ru" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_sr" type="text" indexed="true" stored="true" multiValued="false" /> <!-- not currently supported -->
<dynamicField name="*_sv" type="text_sv" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_tr" type="text_tr" indexed="true" stored="true" multiValued="false" termVectors="true" />
<dynamicField name="*_uk" type="text" indexed="true" stored="true" multiValued="false" termVectors="true" /> <!-- not currently supported -->
<dynamicField name="*_vi" type="text" indexed="true" stored="true" multiValued="false" termVectors="true" /> <!-- not currently supported -->
<!--TODO: Activate<dynamicField name="*_zh_CN" type="text_cjk" indexed="true" stored="true" multiValued="false" />-->
<!--TODO: Activate<dynamicField name="*_zh_TW" type="text_cjk" indexed="true" stored="true" multiValued="false" />-->
<dynamicField name="*_txt" type="text" indexed="true" stored="true" multiValued="false" />
Expand Down

0 comments on commit 601aef5

Please sign in to comment.